From: Tom Lane <tgl@sss.pgh.pa.us>
To: Hristo Ivanov <hristo.atanassov@gmail.com>
Cc: Andrew Gierth <andrew@tao11.riddles.org.uk>
Cc: pgsql-bugs@postgresql.org
Subject: Re: information_schema.check_constraints Inconsistencies
Date: Wed, 19 Sep 2018 10:33:22 -0400
Message-ID: <13869.1537367602@sss.pgh.pa.us> (raw)
In-Reply-To: <CAAH_5C-MP2ZEGH=qwzSM4bDvkya1YhF4tY3w5h1QqiZGiywJMQ@mail.gmail.com>
References: <CAAH_5C-tihAowcB2qi7mrRn+oCQV=EitoCyhLcVja9j=kbbZ-g@mail.gmail.com>
<87fty6io5z.fsf@news-spur.riddles.org.uk>
<CAAH_5C-MP2ZEGH=qwzSM4bDvkya1YhF4tY3w5h1QqiZGiywJMQ@mail.gmail.com>
Hristo Ivanov <hristo.atanassov@gmail.com> writes:
> 2018-09-18 22:59 GMT+03:00 Andrew Gierth <andrew@tao11.riddles.org.uk>:
>> 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.
> I didn't know that constraint names had to be unique. Even if that is true,
> I don't think returning wrong constraints in this case (belonging to a
> different table) is the right thing to do. This means that PostgreSQL is
> conforming to the standard in only places, while the dependencies are
> clearly not standard compliant. Since the likelihood of fixing dependencies
> is fairly small, I would suggest fixing the constraints selection behavior.
It was already explained to you that we're not changing this. The
information_schema outputs conform to the spec as long as the inputs
(i.e., the set of constraint names created by your application) do.
It's not very plausible to insist on spec compliance for what you see
in information_schema when the violation is your own fault. Moreover,
the only thing we could do to make the situation more compliant would
be to enforce constraint name uniqueness schema-wide, which is not really
very desirable (on any metric other than blind standards compliance)
and would create major backwards-compatibility issues. So no, it's not
going to change.
> Fair enough. Could I suggest having a column to discriminate non-null
> constraints from the rest?
Not in the information_schema you can't :-(. The set of columns in
those views is dictated by the standard. Adding more would just be
another way of not being compliant.
> FYI, the only solution I found to this problem, is: ...
> This completely disregards the information_schema objects.
Yup, if you want to deal with non-standard-compliant objects or
situations, you generally need to ignore information_schema and
look directly at the catalogs.
regards, tom lane
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: tgl@sss.pgh.pa.us, hristo.atanassov@gmail.com, andrew@tao11.riddles.org.uk
Subject: Re: information_schema.check_constraints Inconsistencies
In-Reply-To: <13869.1537367602@sss.pgh.pa.us>
References: <CAAH_5C-tihAowcB2qi7mrRn+oCQV=EitoCyhLcVja9j=kbbZ-g@mail.gmail.com> <87fty6io5z.fsf@news-spur.riddles.org.uk> <CAAH_5C-MP2ZEGH=qwzSM4bDvkya1YhF4tY3w5h1QqiZGiywJMQ@mail.gmail.com> <13869.1537367602@sss.pgh.pa.us>
* 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