Fix copying/equality-check bugs in GrantStmt and ConstraintsSetStmt,

per reports from Fernando Nasser.  Also, rearrange order of declarations
in parsenodes.h as suggested by Fernando.
This commit is contained in:
Tom Lane 2002-03-08 04:37:18 +00:00
parent 54f4136aca
commit cf68a686a6
5 changed files with 893 additions and 925 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.104 2002/03/06 06:09:36 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.105 2002/03/08 04:37:14 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1781,6 +1781,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
foreach(l, stmt->constraints)
{
char *cname = strVal(lfirst(l));
ScanKeyData skey;
SysScanDesc tgscan;
HeapTuple htup;
@ -1788,7 +1789,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
/*
* Check that only named constraints are set explicitly
*/
if (strcmp((char *) lfirst(l), "") == 0)
if (strlen(cname) == 0)
elog(ERROR, "unnamed constraints cannot be set explicitly");
/*
@ -1798,7 +1799,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
(bits16) 0x0,
(AttrNumber) Anum_pg_trigger_tgconstrname,
(RegProcedure) F_NAMEEQ,
PointerGetDatum((char *) lfirst(l)));
PointerGetDatum(cname));
tgscan = systable_beginscan(tgrel, TriggerConstrNameIndex, true,
SnapshotNow, 1, &skey);
@ -1822,7 +1823,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_UPD &&
pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_DEL)
elog(ERROR, "Constraint '%s' is not deferrable",
(char *) lfirst(l));
cname);
constr_oid = htup->t_data->t_oid;
loid = lappendi(loid, constr_oid);
@ -1835,7 +1836,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
* Not found ?
*/
if (!found)
elog(ERROR, "Constraint '%s' does not exist", (char *) lfirst(l));
elog(ERROR, "Constraint '%s' does not exist", cname);
}
heap_close(tgrel, AccessShareLock);

View File

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.167 2002/03/07 16:35:34 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.168 2002/03/08 04:37:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1898,7 +1898,7 @@ _copyGrantStmt(GrantStmt *from)
newnode->is_grant = from->is_grant;
newnode->objtype = from->objtype;
Node_Copy(from, newnode, objects);
Node_Copy(from, newnode, privileges);
newnode->privileges = listCopy(from->privileges);
Node_Copy(from, newnode, grantees);
return newnode;
@ -1924,8 +1924,6 @@ _copyFuncWithArgs(FuncWithArgs *from)
if (from->funcname)
newnode->funcname = pstrdup(from->funcname);
else
newnode->funcname = NULL;
Node_Copy(from, newnode, funcargs);
return newnode;

View File

@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.115 2002/03/07 16:35:34 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.116 2002/03/08 04:37:16 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -763,7 +763,7 @@ _equalGrantStmt(GrantStmt *a, GrantStmt *b)
return false;
if (!equal(a->objects, b->objects))
return false;
if (!equal(a->privileges, b->privileges))
if (!equali(a->privileges, b->privileges))
return false;
if (!equal(a->grantees, b->grantees))
return false;

View File

@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.287 2002/03/07 16:35:35 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.288 2002/03/08 04:37:17 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@ -286,7 +286,6 @@ static void doNegateFloat(Value *v);
ConstraintTimeSpec
%type <list> constraints_set_list
%type <list> constraints_set_namelist
%type <boolean> constraints_set_mode
/*
@ -1034,37 +1033,12 @@ ConstraintsSetStmt: SET CONSTRAINTS constraints_set_list constraints_set_mode
}
;
constraints_set_list: ALL
{
$$ = NIL;
}
| constraints_set_namelist
{
$$ = $1;
}
constraints_set_list: ALL { $$ = NIL; }
| name_list { $$ = $1; }
;
constraints_set_namelist: ColId
{
$$ = makeList1($1);
}
| constraints_set_namelist ',' ColId
{
$$ = lappend($1, $3);
}
;
constraints_set_mode: DEFERRED
{
$$ = TRUE;
}
| IMMEDIATE
{
$$ = FALSE;
}
constraints_set_mode: DEFERRED { $$ = TRUE; }
| IMMEDIATE { $$ = FALSE; }
;

File diff suppressed because it is too large Load Diff