From 060baf27844163c0874c72d7baf08d3bf9a8ffce Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 30 Jul 2009 02:45:38 +0000 Subject: 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. --- src/backend/commands/trigger.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/backend/commands/trigger.c') 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, "") == 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; -- cgit v1.2.3