Open rvo-cs opened 1 year ago
Yes, this is indeed one of many limitations of the current implementation.
I agree it's allowed to create a private synonym for a public synonym, but it is strange and IMO a corner case.
In your example you created the following synonym chains:
I did not drop the synonyms and the dba_dependencies looked like this:
OWNER NAME TYPE REFERENCED_OWNER REFERENCED_NAME REFERENCED_TYPE REFERENCED_LINK_NAME DEPENDENCY_TYPE
------ ----- ------- ---------------- --------------- ------------------- -------------------- ---------------
PUBLIC S_TC SYNONYM SCOTT TC TABLE HARD
PUBLIC S2_TC SYNONYM SCOTT S_TC SYNONYM HARD
PUBLIC S_VD SYNONYM SCOTT VD VIEW HARD
SCOTT S_TC SYNONYM PUBLIC S_TC SYNONYM HARD
SCOTT VD VIEW PUBLIC S2_TC SYNONYM HARD
SCOTT S_VD SYNONYM PUBLIC S_VD SYNONYM HARD
PUBLIC S2_VD SYNONYM SCOTT S_VD SYNONYM HARD
SCOTT VE VIEW PUBLIC S2_VD SYNONYM HARD
8 rows selected.
After dropping the private synonyms s_tc
and s_vd
the dba_dependencies look like this:
OWNER NAME TYPE REFERENCED_OWNER REFERENCED_NAME REFERENCED_TYPE REFERENCED_LINK_NAME DEPENDENCY_TYPE
------ ----- ------- ---------------- --------------- ------------------- -------------------- ---------------
PUBLIC S_TC SYNONYM SCOTT TC TABLE HARD
PUBLIC S2_TC SYNONYM SCOTT S_TC NON-EXISTENT HARD
PUBLIC S_VD SYNONYM SCOTT VD VIEW HARD
SCOTT VD VIEW PUBLIC S2_TC SYNONYM HARD
PUBLIC S2_VD SYNONYM SCOTT S_VD NON-EXISTENT HARD
SCOTT VE VIEW PUBLIC S2_VD SYNONYM HARD
6 rows selected.
The dependency chain changed to:
That we have to deal with a referenced_type NON-EXISTENT
is just another corner case.
Nonetheless I agree that the result of this case could be improved. - I consider this an enhancement request.
The public synonym has to depend on the NON-EXISTENT
object, so it's invalidated if an object with the referenced name is created again in the schema of the referenced owner.
And I totally agree, chains of synonyms are infrequent and mostly corner cases.
In keeping with issue #63, chains of synonyms are not traversed by the
lineage_util
package.Reason:
dd_util.resolve_synonym
performs only a "shallow" resolution, as opposed to "in-depth" resolution of chains of synonyms, up to the first non-synonym object (if any) at the end of the chain.Test case:
Actual:
Expected:
This is arguably a made-up test case, for an edge case; yet it's perfectly legal, so it could be found.
Solution: for completeness,
dd_util.resolve_synonym
should be expanded in order to perform in-depth resolution of chains of synonyms—perhaps with an option to perform shallow resolution if needed, but in-depth resolution should be the default.