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

Commit26b7abf

Browse files
committed
Fix ALTER LARGE OBJECT and GRANT ... ON LARGE OBJECT for large OIDs.
The previous coding failed for OIDs too large to be represented bya signed integer.
1 parenta079efa commit26b7abf

File tree

6 files changed

+42
-40
lines changed

6 files changed

+42
-40
lines changed

‎src/backend/catalog/aclchk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.166 2010/04/05 01:58:03 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/aclchk.c,v 1.167 2010/06/13 17:43:12 rhaas Exp $
1212
*
1313
* NOTES
1414
* See acl.h.
@@ -47,6 +47,7 @@
4747
#include"miscadmin.h"
4848
#include"parser/parse_func.h"
4949
#include"utils/acl.h"
50+
#include"utils/builtins.h"
5051
#include"utils/fmgroids.h"
5152
#include"utils/lsyscache.h"
5253
#include"utils/rel.h"
@@ -647,7 +648,7 @@ objectNamesToOids(GrantObjectType objtype, List *objnames)
647648
caseACL_OBJECT_LARGEOBJECT:
648649
foreach(cell,objnames)
649650
{
650-
OidlobjOid=intVal(lfirst(cell));
651+
OidlobjOid=oidparse(lfirst(cell));
651652

652653
if (!LargeObjectExists(lobjOid))
653654
ereport(ERROR,

‎src/backend/commands/alter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.35 2010/02/26 02:00:37 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.36 2010/06/13 17:43:12 rhaas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -31,6 +31,7 @@
3131
#include"parser/parse_clause.h"
3232
#include"tcop/utility.h"
3333
#include"utils/acl.h"
34+
#include"utils/builtins.h"
3435
#include"utils/lsyscache.h"
3536

3637

@@ -235,7 +236,7 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
235236
break;
236237

237238
caseOBJECT_LARGEOBJECT:
238-
LargeObjectAlterOwner(intVal(linitial(stmt->object)),newowner);
239+
LargeObjectAlterOwner(oidparse(linitial(stmt->object)),newowner);
239240
break;
240241

241242
caseOBJECT_OPERATOR:

‎src/backend/commands/comment.c

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.114 2010/02/26 02:00:38 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.115 2010/06/13 17:43:12 rhaas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1404,32 +1404,9 @@ static void
14041404
CommentLargeObject(List*qualname,char*comment)
14051405
{
14061406
Oidloid;
1407-
Node*node;
14081407

14091408
Assert(list_length(qualname)==1);
1410-
node= (Node*)linitial(qualname);
1411-
1412-
switch (nodeTag(node))
1413-
{
1414-
caseT_Integer:
1415-
loid=intVal(node);
1416-
break;
1417-
caseT_Float:
1418-
1419-
/*
1420-
* Values too large for int4 will be represented as Float
1421-
* constants by the lexer.Accept these if they are valid OID
1422-
* strings.
1423-
*/
1424-
loid=DatumGetObjectId(DirectFunctionCall1(oidin,
1425-
CStringGetDatum(strVal(node))));
1426-
break;
1427-
default:
1428-
elog(ERROR,"unrecognized node type: %d",
1429-
(int)nodeTag(node));
1430-
/* keep compiler quiet */
1431-
loid=InvalidOid;
1432-
}
1409+
loid=oidparse((Node*)linitial(qualname));
14331410

14341411
/* check that the large object exists */
14351412
if (!LargeObjectExists(loid))

‎src/backend/parser/gram.y

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.712 2010/05/30 18:10:40 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.713 2010/06/13 17:43:12 rhaas Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -365,6 +365,7 @@ static TypeName *TableFuncTypeName(List *columns);
365365
%type<list>OptCreateAsCreateAsList
366366
%type<node>CreateAsElementctext_expr
367367
%type<value>NumericOnly
368+
%type<list>NumericOnly_list
368369
%type<alias>alias_clause
369370
%type<sortby>sortby
370371
%type<ielem>index_elem
@@ -399,7 +400,6 @@ static TypeName *TableFuncTypeName(List *columns);
399400
%type<boolean>opt_varyingopt_timezone
400401

401402
%type<ival>IconstSignedIconst
402-
%type<list>Iconst_list
403403
%type<str>Sconstcomment_textnotify_payload
404404
%type<str>RoleIdopt_granted_byopt_booleanColId_or_Sconst
405405
%type<list>var_list
@@ -2879,6 +2879,10 @@ NumericOnly:
28792879
|SignedIconst{$$ = makeInteger($1); }
28802880
;
28812881

2882+
NumericOnly_list:NumericOnly{$$ = list_make1($1); }
2883+
|NumericOnly_list','NumericOnly{$$ = lappend($1,$3); }
2884+
;
2885+
28822886
/*****************************************************************************
28832887
*
28842888
*QUERIES :
@@ -4634,7 +4638,7 @@ privilege_target:
46344638
n->objs =$2;
46354639
$$ = n;
46364640
}
4637-
| LARGE_P OBJECT_PIconst_list
4641+
| LARGE_P OBJECT_PNumericOnly_list
46384642
{
46394643
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
46404644
n->targtype = ACL_TARGET_OBJECT;
@@ -5929,11 +5933,11 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleId
59295933
n->newowner =$7;
59305934
$$ = (Node *)n;
59315935
}
5932-
| ALTER LARGE_P OBJECT_PIconst OWNER TO RoleId
5936+
| ALTER LARGE_P OBJECT_PNumericOnly OWNER TO RoleId
59335937
{
59345938
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
59355939
n->objectType = OBJECT_LARGEOBJECT;
5936-
n->object = list_make1(makeInteger($4));
5940+
n->object = list_make1($4);
59375941
n->newowner =$7;
59385942
$$ = (Node *)n;
59395943
}
@@ -10755,10 +10759,6 @@ SignedIconst: Iconst{ $$ = $1; }
1075510759
|'-' Iconst{ $$ = - $2; }
1075610760
;
1075710761

10758-
Iconst_list:Iconst{ $$ =list_make1(makeInteger($1)); }
10759-
| Iconst_list',' Iconst{ $$ =lappend($1,makeInteger($3)); }
10760-
;
10761-
1076210762
/*
1076310763
* Name classification hierarchy.
1076410764
*

‎src/backend/utils/adt/oid.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.76 2010/01/02 16:57:54 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/oid.c,v 1.77 2010/06/13 17:43:13 rhaas Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -303,6 +303,28 @@ oidvectorsend(PG_FUNCTION_ARGS)
303303
returnarray_send(fcinfo);
304304
}
305305

306+
/*
307+
*oidparse- get OID from IConst/FConst node
308+
*/
309+
Oid
310+
oidparse(Node*node)
311+
{
312+
switch (nodeTag(node))
313+
{
314+
caseT_Integer:
315+
returnintVal(node);
316+
caseT_Float:
317+
/*
318+
* Values too large for int4 will be represented as Float constants
319+
* by the lexer. Accept these if they are valid OID strings.
320+
*/
321+
returnoidin_subr(strVal(node),NULL);
322+
default:
323+
elog(ERROR,"unrecognized node type: %d", (int)nodeTag(node));
324+
}
325+
returnInvalidOid;/* keep compiler quiet */
326+
}
327+
306328

307329
/*****************************************************************************
308330
* PUBLIC ROUTINES *

‎src/include/utils/builtins.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.348 2010/02/26 02:01:28 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.349 2010/06/13 17:43:13 rhaas Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -479,6 +479,7 @@ extern Datum oidvectorle(PG_FUNCTION_ARGS);
479479
externDatumoidvectorge(PG_FUNCTION_ARGS);
480480
externDatumoidvectorgt(PG_FUNCTION_ARGS);
481481
externoidvector*buildoidvector(constOid*oids,intn);
482+
externOidoidparse(Node*node);
482483

483484
/* pseudotypes.c */
484485
externDatumcstring_in(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp