Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf68a68

Browse files
committed
Fix copying/equality-check bugs in GrantStmt and ConstraintsSetStmt,
per reports from Fernando Nasser. Also, rearrange order of declarationsin parsenodes.h as suggested by Fernando.
1 parent54f4136 commitcf68a68

File tree

5 files changed

+945
-977
lines changed

5 files changed

+945
-977
lines changed

‎src/backend/commands/trigger.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.104 2002/03/06 06:09:36 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.105 2002/03/08 04:37:14 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1781,14 +1781,15 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
17811781

17821782
foreach(l,stmt->constraints)
17831783
{
1784+
char*cname=strVal(lfirst(l));
17841785
ScanKeyDataskey;
17851786
SysScanDesctgscan;
17861787
HeapTuplehtup;
17871788

17881789
/*
17891790
* Check that only named constraints are set explicitly
17901791
*/
1791-
if (strcmp((char*)lfirst(l),"")==0)
1792+
if (strlen(cname)==0)
17921793
elog(ERROR,"unnamed constraints cannot be set explicitly");
17931794

17941795
/*
@@ -1798,7 +1799,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
17981799
(bits16)0x0,
17991800
(AttrNumber)Anum_pg_trigger_tgconstrname,
18001801
(RegProcedure)F_NAMEEQ,
1801-
PointerGetDatum((char*)lfirst(l)));
1802+
PointerGetDatum(cname));
18021803

18031804
tgscan=systable_beginscan(tgrel,TriggerConstrNameIndex, true,
18041805
SnapshotNow,1,&skey);
@@ -1822,7 +1823,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
18221823
pg_trigger->tgfoid!=F_RI_FKEY_RESTRICT_UPD&&
18231824
pg_trigger->tgfoid!=F_RI_FKEY_RESTRICT_DEL)
18241825
elog(ERROR,"Constraint '%s' is not deferrable",
1825-
(char*)lfirst(l));
1826+
cname);
18261827

18271828
constr_oid=htup->t_data->t_oid;
18281829
loid=lappendi(loid,constr_oid);
@@ -1835,7 +1836,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
18351836
* Not found ?
18361837
*/
18371838
if (!found)
1838-
elog(ERROR,"Constraint '%s' does not exist",(char*)lfirst(l));
1839+
elog(ERROR,"Constraint '%s' does not exist",cname);
18391840
}
18401841
heap_close(tgrel,AccessShareLock);
18411842

‎src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.167 2002/03/07 16:35:34 momjian Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.168 2002/03/08 04:37:16 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1898,7 +1898,7 @@ _copyGrantStmt(GrantStmt *from)
18981898
newnode->is_grant=from->is_grant;
18991899
newnode->objtype=from->objtype;
19001900
Node_Copy(from,newnode,objects);
1901-
Node_Copy(from,newnode,privileges);
1901+
newnode->privileges=listCopy(from->privileges);
19021902
Node_Copy(from,newnode,grantees);
19031903

19041904
returnnewnode;
@@ -1924,8 +1924,6 @@ _copyFuncWithArgs(FuncWithArgs *from)
19241924

19251925
if (from->funcname)
19261926
newnode->funcname=pstrdup(from->funcname);
1927-
else
1928-
newnode->funcname=NULL;
19291927
Node_Copy(from,newnode,funcargs);
19301928

19311929
returnnewnode;

‎src/backend/nodes/equalfuncs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Portions Copyright (c) 1994, Regents of the University of California
2121
*
2222
* IDENTIFICATION
23-
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.115 2002/03/07 16:35:34 momjian Exp $
23+
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.116 2002/03/08 04:37:16 tgl Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -763,7 +763,7 @@ _equalGrantStmt(GrantStmt *a, GrantStmt *b)
763763
return false;
764764
if (!equal(a->objects,b->objects))
765765
return false;
766-
if (!equal(a->privileges,b->privileges))
766+
if (!equali(a->privileges,b->privileges))
767767
return false;
768768
if (!equal(a->grantees,b->grantees))
769769
return false;

‎src/backend/parser/gram.y

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.287 2002/03/07 16:35:35 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.288 2002/03/08 04:37:17 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -286,7 +286,6 @@ static void doNegateFloat(Value *v);
286286
ConstraintTimeSpec
287287

288288
%type<list>constraints_set_list
289-
%type<list>constraints_set_namelist
290289
%type<boolean>constraints_set_mode
291290

292291
/*
@@ -1034,37 +1033,12 @@ ConstraintsSetStmt:SET CONSTRAINTS constraints_set_list constraints_set_mode
10341033
}
10351034
;
10361035

1037-
1038-
constraints_set_list:ALL
1039-
{
1040-
$$ = NIL;
1041-
}
1042-
|constraints_set_namelist
1043-
{
1044-
$$ =$1;
1045-
}
1036+
constraints_set_list:ALL{$$ = NIL; }
1037+
|name_list{$$ =$1; }
10461038
;
10471039

1048-
1049-
constraints_set_namelist:ColId
1050-
{
1051-
$$ = makeList1($1);
1052-
}
1053-
|constraints_set_namelist','ColId
1054-
{
1055-
$$ = lappend($1,$3);
1056-
}
1057-
;
1058-
1059-
1060-
constraints_set_mode:DEFERRED
1061-
{
1062-
$$ =TRUE;
1063-
}
1064-
|IMMEDIATE
1065-
{
1066-
$$ =FALSE;
1067-
}
1040+
constraints_set_mode:DEFERRED{$$ =TRUE; }
1041+
|IMMEDIATE{$$ =FALSE; }
10681042
;
10691043

10701044

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp