-
Notifications
You must be signed in to change notification settings - Fork 4.1k
tabledesc: GetReferencedDescIDs is incorrect #77140
Copy link
Copy link
Open
Labels
A-schema-descriptorsRelating to SQL table/db descriptor handling.Relating to SQL table/db descriptor handling.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Metadata
Metadata
Assignees
Labels
A-schema-descriptorsRelating to SQL table/db descriptor handling.Relating to SQL table/db descriptor handling.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)
The contract for the
GetReferencedDescIDsmethod incatalog.Descriptoris to return the set of all descriptor IDs referenced by a descriptor: itself, its parents, forward references, backward references, etc. This method is used for cross-descriptor validation to retrieve all the descriptors which might have forward or back-references to the validated descriptor.Currently, it appears that there are some edge cases for which
GetReferencedDescIDsdoes not behave correctly. These involve user-defined types. Notice thatGetAllReferencedTypeIDsand by extensiongetAllReferencedTypesInTableColumnsreturn the ID closure of any referenced type descriptor. This is a fancy word for transitive dependencies. Practically speaking:will create an enum type
greetingand also an alias type_greetingwhich represents the array typegreeting[]. It so happens thatwill create a table descriptor for
foowhich contains a forward reference togreetingvia its columnx. However, counterintuitively, back-references tofoowill be added in bothgreetingas well as_greeting.All this can be quite easily verified in a unit test which:
desctestutilsfunctionGetAllReferencedTypeIDsreturns both type descriptor IDs (this is correct)GetReferencedDescIDsonly returns one type descriptor ID (this is incorrect, and is the bug that needs to be fixed)Jira issue: CRDB-13429
Epic CRDB-30352