pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
To: Kirill Reshke <reshkekirill@gmail.com>
Cc: keeshd@keeshinds.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19352: SQL Error messages do not include schema name along with table or data object name.
Date: Fri, 12 Dec 2025 16:10:48 +0100
Message-ID: <202512121504.x4f5zza4r47m@alvherre.pgsql> (raw)
In-Reply-To: <CALdSSPhrTa8oqJpXm3TZVfkMUC5mgnFgrQXfs0chkjaG9YRu9Q@mail.gmail.com>

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)





view thread (4+ messages)  latest in thread

Message-ID: <202512121504.x4f5zza4r47m@alvherre.pgsql>
Permalink:  ../202512121504.x4f5zza4r47m@alvherre.pgsql/
Also on:    postgresql.org/message-id/202512121504.x4f5zza4r47m@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: alvherre@kurilemu.de, reshkekirill@gmail.com, keeshd@keeshinds.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #19352: SQL Error messages do not include schema name along with table or data object name.
  In-Reply-To: <202512121504.x4f5zza4r47m@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox