diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-30 02:45:38 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-07-30 02:45:38 +0000 |
commit | 060baf27844163c0874c72d7baf08d3bf9a8ffce (patch) | |
tree | b011e0000cb299f0c9ffb634931e30fcec3d2094 /src/backend/commands/trigger.c | |
parent | 78aef14c5935bca92d0cacaa9d188f588d7f2444 (diff) | |
download | postgresql-060baf27844163c0874c72d7baf08d3bf9a8ffce.tar.gz postgresql-060baf27844163c0874c72d7baf08d3bf9a8ffce.zip |
Merge the Constraint and FkConstraint node types into a single type.
This was foreseen to be a good idea long ago, but nobody had got round
to doing it. The recent patch for deferred unique constraints made
transformConstraintAttrs() ugly enough that I decided it was time.
This change will also greatly simplify parsing of deferred CHECK constraints,
if anyone ever gets around to implementing that.
While at it, add a location field to Constraint, and use that to provide
an error cursor for some of the constraint-related error messages.
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r-- | src/backend/commands/trigger.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index b84731126a1..7bc82127893 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.250 2009/07/29 20:56:18 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.251 2009/07/30 02:45:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -607,12 +607,14 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid) /* OK, we have a set, so make the FK constraint ALTER TABLE cmd */ AlterTableStmt *atstmt = makeNode(AlterTableStmt); AlterTableCmd *atcmd = makeNode(AlterTableCmd); - FkConstraint *fkcon = makeNode(FkConstraint); + Constraint *fkcon = makeNode(Constraint); ereport(NOTICE, (errmsg("converting trigger group into constraint \"%s\" %s", constr_name, buf.data), errdetail("%s", _(funcdescr[funcnum])))); + fkcon->contype = CONSTR_FOREIGN; + fkcon->location = -1; if (funcnum == 2) { /* This trigger is on the FK table */ @@ -642,9 +644,9 @@ ConvertTriggerToFK(CreateTrigStmt *stmt, Oid funcoid) atcmd->subtype = AT_AddConstraint; atcmd->def = (Node *) fkcon; if (strcmp(constr_name, "<unnamed>") == 0) - fkcon->constr_name = NULL; + fkcon->conname = NULL; else - fkcon->constr_name = constr_name; + fkcon->conname = constr_name; fkcon->fk_attrs = fk_attrs; fkcon->pk_attrs = pk_attrs; fkcon->fk_matchtype = fk_matchtype; |