From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Hristo Ivanov <hristo.atanassov@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: information_schema.check_constraints Inconsistencies
Date: Tue, 18 Sep 2018 20:59:10 +0100
Message-ID: <87fty6io5z.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAAH_5C-tihAowcB2qi7mrRn+oCQV=EitoCyhLcVja9j=kbbZ-g@mail.gmail.com>
References: <CAAH_5C-tihAowcB2qi7mrRn+oCQV=EitoCyhLcVja9j=kbbZ-g@mail.gmail.com>
>>>>> "Hristo" == Hristo Ivanov <hristo.atanassov@gmail.com> writes:
Hristo> Hello,
Hristo> I am writing with regards to some wrong results I keep on
Hristo> receiving when using check_constraints view from
Hristo> information_schema:
Hristo> (1) First, it shows constraints grouped by name, regardless of
Hristo> the relation used: when having two constraints with the same
Hristo> name in different tables, it shows both in both tables,
Hristo> regardless of their belonging;
In the SQL spec, the name of a constraint is not local to the table; in
a given schema, the name must be unique. PostgreSQL does not enforce
this, and generally treats constraint names as local to a single
_table_; this is difficult to fix retroactively because it would make
old databases fail to restore if the spec's conditions were enforced.
https://wiki.postgresql.org/wiki/PostgreSQL_vs_SQL_Standard#Constraint_name_scope
Hristo> (2) Second, it also lists NOT NULL constraints, even though
Hristo> they are not created as check constraints.
This is required by the SQL spec, which treats NOT NULL as merely a
syntactic shorthand for CHECK(colname IS NOT NULL). But see also
https://wiki.postgresql.org/wiki/PostgreSQL_vs_SQL_Standard#NOT_NULL_constraints_on_composite-type_c...
which implies that for composite-type columns, NOT NULL and
CHECK(colname IS NOT NULL) actually have different semantics in PG.
--
Andrew (irc:RhodiumToad)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, hristo.atanassov@gmail.com
Subject: Re: information_schema.check_constraints Inconsistencies
In-Reply-To: <87fty6io5z.fsf@news-spur.riddles.org.uk>
References: <CAAH_5C-tihAowcB2qi7mrRn+oCQV=EitoCyhLcVja9j=kbbZ-g@mail.gmail.com> <87fty6io5z.fsf@news-spur.riddles.org.uk>
* 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