On Wed, 1 Jan 2003, Bruce Momjian wrote:

> Tom Lane wrote:
> > Bruce Momjian <[EMAIL PROTECTED]> writes:
> > > I see the values being stored on constriant creation, but not being used
> > > anywhere:
> >
> > I believe the values that actually get inspected at runtime are the
> > tgdeferrable and tginitdeferred fields in pg_trigger.  The columns in
> > pg_constraint are just copies of these.
> >
> > It is not real clear to me whether it should be allowed to alter the
> > deferrability status of a foreign-key constraint --- is that in the spec?
>
> The big problem is that while pg_dump's dump_trigger() looks at
> tginitdeferred and dumps accordingly, pg_get_constraintdef doesn't look
> at tginitdeferred, and therefore doesn't record the requirement as part
> of ALTER TABLE ADD CONSTRAINT.

pg_get_constraintdef should probably be looking at condeferrable
and condeferred in the pg_constraint row it's looking at.  Maybe something
like the attached.
*** pgsql/src/backend/utils/adt/ruleutils.c     2003-01-01 15:03:35.000000000 -0800
--- pgsql/src/backend/utils/adt/ruleutils.c.new 2003-01-01 15:02:32.000000000 -0800
***************
*** 688,693 ****
--- 688,704 ----
                                }
                                appendStringInfo(&buf, " ON DELETE %s", string);
  
+                               if (!conForm->condeferrable) {
+                                       appendStringInfo(&buf, " NOT");
+                               }
+                               appendStringInfo(&buf, " DEFERRABLE");
+                               if (conForm->condeferred) {
+                                       appendStringInfo(&buf, " INITIALLY DEFERRED");
+                               }
+                               else {
+                                       appendStringInfo(&buf, " INITIALLY 
+IMMEDIATE");
+                               }
+ 
                                break;
                        }
  
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to