mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
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.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user