Re: Identifying Schema-Qualified Sequence References in Column Defaults

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jiaoshuntian(at)highgo(dot)com(dot)w(dot)kunlunaq(dot)com
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Identifying Schema-Qualified Sequence References in Column Defaults
Date: 2025-10-23 02:40:10
Message-ID: 1209719.1761187210@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

jiaoshuntian(at)highgo(dot)com(dot)w(dot)kunlunaq(dot)com writes:
> I'd like to bring attention to a metadata visibility issue when multiple schemas contain sequences with identical names, and a table column references one of them via nextval(). Currently, there appears to be no reliable way to determine which schema's sequence is actually referenced through system catalogs or views.

The documented behavior of type regclass is that it schema-qualifies
the output name if the table/sequence/whatever would not be found by
searching the current search_path. If you want something more
predictable, you could "set search_path = pg_catalog" before
inspecting the system catalogs.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-10-23 02:43:13 Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part
Previous Message jiaoshuntian 2025-10-23 02:31:01 Identifying Schema-Qualified Sequence References in Column Defaults