Re: Review: Non-inheritable check constraints - Mailing list pgsql-hackers

From Alex Hunsaker
Subject Re: Review: Non-inheritable check constraints
Date
Msg-id CAFaPBrT=86iA2fCc2pe2LwpDORLz5PjqjvEyi8NTN1TEF5kizA@mail.gmail.com
Whole thread Raw
In response to Re: Review: Non-inheritable check constraints  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Review: Non-inheritable check constraints
List pgsql-hackers
On Fri, Dec 16, 2011 at 12:06, Alvaro Herrera
<alvherre@commandprompt.com> wrote:

> Yeah.  Nikhil, Alex, this is the merged patch.  Have a look that it
> still works for you (particularly the pg_dump bits) and I'll commit it.
> I adjusted the regression test a bit too.

Other than the version checks seem to be off by one looks fine. I
assume I/we missed that in the original patch. I also adjusted the
version check in describe.c to be consistent with the other version
checks in that file (>= 90200 instead of > 90100).

(Also, nice catch on "false AS as r.conisonly" in describe.c)

--

*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
***************
*** 5996,6003 **** getTableAttrs(TableInfo *tblinfo, int numTables)                           tbinfo->dobj.name);
             resetPQExpBuffer(q);
!             if (g_fout->remoteVersion >= 90100)             {                 appendPQExpBuffer(q, "SELECT tableoid,
oid,conname, "                            "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
      "conislocal, convalidated, conisonly " 
--- 5996,6004 ----                           tbinfo->dobj.name);
             resetPQExpBuffer(q);
!             if (g_fout->remoteVersion >= 90200)             {
+                 /* conisonly is new in 9.2 */                 appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
                         "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
"conislocal,convalidated, conisonly " 
***************
*** 6007,6012 **** getTableAttrs(TableInfo *tblinfo, int numTables)
--- 6008,6026 ----                                   "ORDER BY conname",
tbinfo->dobj.catId.oid);            } 
+             else if (g_fout->remoteVersion >= 90100)
+             {
+                 /* conisvalidated is new in 9.1 */
+                 appendPQExpBuffer(q, "SELECT tableoid, oid, conname, "
+                            "pg_catalog.pg_get_constraintdef(oid) AS consrc, "
+                                   "conislocal, convalidated, "
+                                   "false as conisonly "
+                                   "FROM pg_catalog.pg_constraint "
+                                   "WHERE conrelid = '%u'::pg_catalog.oid "
+                                   "   AND contype = 'c' "
+                                   "ORDER BY conname",
+                                   tbinfo->dobj.catId.oid);
+             }             else if (g_fout->remoteVersion >= 80400)             {                 appendPQExpBuffer(q,
"SELECTtableoid, oid, conname, " 
*** a/src/bin/psql/describe.c
--- b/src/bin/psql/describe.c
***************
*** 1783,1789 **** describeOneTableDetails(const char *schemaname,         {             char *is_only;

!             if (pset.sversion > 90100)                 is_only = "r.conisonly";             else
is_only= "false AS conisonly"; 
--- 1783,1789 ----         {             char *is_only;

!             if (pset.sversion >= 90200)                 is_only = "r.conisonly";             else
is_only= "false AS conisonly"; 


pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: WIP: cross column stats revisited ...
Next
From: Alvaro Herrera
Date:
Subject: Re: Review: Non-inheritable check constraints