| From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
|---|---|
| To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Cc: | keeshd(at)keeshinds(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: BUG #19352: SQL Error messages do not include schema name along with table or data object name. |
| Date: | 2025-12-12 15:10:48 |
| Message-ID: | 202512121504.x4f5zza4r47m@alvherre.pgsql |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Actually, these error reports do include a schema name among other
things -- it's just hidden from view. For psql it's very easy to make
them visible, just use
\set VERBOSITY verbose
Then the error message includes more detail:
=# insert into sh.t2 values (1);
ERROR: 23503: insert or update on table "t2" violates foreign key constraint "t2_i_fkey"
DETAIL: Key (i)=(1) is not present in table "t".
SCHEMA NAME: sh
TABLE NAME: t2
CONSTRAINT NAME: t2_i_fkey
LOCATION: ri_ReportViolation, ri_triggers.c:2770
Other clients would have their own ways to display that information.
Kirill Reshke wrote:
> I may be foolish but constraints are not schema-qualified, they just
> have names.
You're not foolish, but the schema name is attached to the table.
You're correct that there can be more than one constraint with the same
name in a schema, but there cannot be more than one constraint with the
same name on the _table_, which is itself uniquely identified by the
schema and its name.
So you could argue that we could improve this by schema-qualifying the
table name (not the constraint name) in this message:
ERROR: 23503: insert or update on table "sh.t2" violates foreign key constraint "t2_i_fkey"
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"No me acuerdo, pero no es cierto. No es cierto, y si fuera cierto,
no me acuerdo." (Augusto Pinochet a una corte de justicia)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2025-12-12 15:26:12 | Re: Bug in sub-query |
| Previous Message | Álvaro Herrera | 2025-12-12 15:01:53 | Re: Re: BUG #19351: in pg18.1,when not null exists in the table , and add constraint problem. |