Fix pg_get_constraintdef to cope with NOT VALID constraints
authorAlvaro Herrera
Thu, 2 Jun 2011 16:39:53 +0000 (12:39 -0400)
committerAlvaro Herrera
Fri, 3 Jun 2011 20:05:34 +0000 (16:05 -0400)
This case was missed when NOT VALID constraints were first introduced in
commit 722bf7017bbe796decc79c1fde03e7a83dae9ada by Simon Riggs on
2011-02-08.  Among other things, it causes pg_dump to omit the NOT VALID
flag when dumping such constraints, which may cause them to fail to
load afterwards, if they contained values failing the constraint.

Per report from Thom Brown.

src/backend/utils/adt/ruleutils.c

index 1595ef032d13dd190861ab8776f93751240f4511..a67f7986a14f82ff1e923c6e111411c618e4c172 100644 (file)
@@ -1373,6 +1373,9 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand,
    if (conForm->condeferred)
        appendStringInfo(&buf, " INITIALLY DEFERRED");
 
+   if (!conForm->convalidated)
+       appendStringInfoString(&buf, " NOT VALID");
+
    /* Cleanup */
    ReleaseSysCache(tup);