cockroach
cockroach copied to clipboard
sql: Serial Type should be judged more properly
Right now we only check if a primary key column has default value expression which use a function with name nextval, this won't be true if we support UDF because builtin functions can be shadowed. A more proper way to achieve this is to compare function OID once that is supported.
This issue is not a big deal since the function in question is only used to send a user notice and it should be rare that user define their function to be nextval. Not a blocker for UDF release.
Jira issue: CRDB-16980
Epic: CRDB-3405
I think the deeper principle here relates to all functions which take regclass or oid arguments. We today accept those as strings but when we serialize them, we need to resolve them to their OIDs and then serialize the numerical value.
The action item here is to take some of the seqexpr logic and generalize it fully such that we track references in expressions by IDs and serialize them with the IDs and to make this true for UDFs that take such inputs.