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

Commit8b6d6cf

Browse files
committed
Remove objname/objargs split for referring to objects
In simpler times, it might have worked to refer to all kinds of objectsby a list of name components and an optional argument list. But thisdoesn't work for all objects, which has resulted in a collection ofhacks to place various other nodes types into these fields, which haveto be unpacked at the other end. This makes it also weird to representlists of such things in the grammar, because they would have to be listsof singleton lists, to make the unpacking work consistently. The otherproblem is that keeping separate name and args fields makes it awkwardto deal with lists of functions.Change that by dropping the objargs field and have objname, renamed toobject, be a generic Node, which can then be flexibly assigned andmanaged using the normal Node mechanisms. In many cases it will stillbe a List of names, in some cases it will be a string Value, for typesit will be the existing Typename, for functions it will now use theexisting ObjectWithArgs node type. Some of the more obscure objecttypes still use somewhat arbitrary nested lists.Reviewed-by: Jim Nasby <Jim.Nasby@BlueTreble.com>Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent550214a commit8b6d6cf

File tree

18 files changed

+610
-635
lines changed

18 files changed

+610
-635
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 246 additions & 201 deletions
Large diffs are not rendered by default.

‎src/backend/commands/alter.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ ExecRenameStmt(RenameStmt *stmt)
385385
Relationrelation;
386386

387387
address=get_object_address(stmt->renameType,
388-
stmt->object,stmt->objarg,
388+
stmt->object,
389389
&relation,
390390
AccessExclusiveLock, false);
391391
Assert(relation==NULL);
@@ -421,8 +421,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
421421
Relationrel;
422422

423423
address=
424-
get_object_address_rv(stmt->objectType,stmt->relation,stmt->objname,
425-
stmt->objargs,&rel,AccessExclusiveLock, false);
424+
get_object_address_rv(stmt->objectType,stmt->relation,(List*)stmt->object,
425+
&rel,AccessExclusiveLock, false);
426426

427427
/*
428428
* If a relation was involved, it would have been opened and locked. We
@@ -431,8 +431,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
431431
if (rel)
432432
heap_close(rel,NoLock);
433433

434-
refAddr=get_object_address(OBJECT_EXTENSION,list_make1(stmt->extname),
435-
NULL,&rel,AccessExclusiveLock, false);
434+
refAddr=get_object_address(OBJECT_EXTENSION,(Node*)stmt->extname,
435+
&rel,AccessExclusiveLock, false);
436436
Assert(rel==NULL);
437437
if (refAddress)
438438
*refAddress=refAddr;
@@ -461,7 +461,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
461461
switch (stmt->objectType)
462462
{
463463
caseOBJECT_EXTENSION:
464-
address=AlterExtensionNamespace(stmt->object,stmt->newschema,
464+
address=AlterExtensionNamespace(strVal((Value*)stmt->object),stmt->newschema,
465465
oldSchemaAddr ?&oldNspOid :NULL);
466466
break;
467467

@@ -476,7 +476,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
476476

477477
caseOBJECT_DOMAIN:
478478
caseOBJECT_TYPE:
479-
address=AlterTypeNamespace(stmt->object,stmt->newschema,
479+
address=AlterTypeNamespace(castNode(List,stmt->object),stmt->newschema,
480480
stmt->objectType,
481481
oldSchemaAddr ?&oldNspOid :NULL);
482482
break;
@@ -501,7 +501,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
501501

502502
address=get_object_address(stmt->objectType,
503503
stmt->object,
504-
stmt->objarg,
505504
&relation,
506505
AccessExclusiveLock,
507506
false);
@@ -764,33 +763,34 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
764763
switch (stmt->objectType)
765764
{
766765
caseOBJECT_DATABASE:
767-
returnAlterDatabaseOwner(strVal(linitial(stmt->object)),newowner);
766+
returnAlterDatabaseOwner(strVal((Value*)stmt->object),newowner);
768767

769768
caseOBJECT_SCHEMA:
770-
returnAlterSchemaOwner(strVal(linitial(stmt->object)),newowner);
769+
returnAlterSchemaOwner(strVal((Value*)stmt->object),newowner);
771770

772771
caseOBJECT_TYPE:
773772
caseOBJECT_DOMAIN:/* same as TYPE */
774-
returnAlterTypeOwner(stmt->object,newowner,stmt->objectType);
773+
returnAlterTypeOwner(castNode(List,stmt->object),newowner,stmt->objectType);
774+
break;
775775

776776
caseOBJECT_FDW:
777-
returnAlterForeignDataWrapperOwner(strVal(linitial(stmt->object)),
777+
returnAlterForeignDataWrapperOwner(strVal((Value*)stmt->object),
778778
newowner);
779779

780780
caseOBJECT_FOREIGN_SERVER:
781-
returnAlterForeignServerOwner(strVal(linitial(stmt->object)),
781+
returnAlterForeignServerOwner(strVal((Value*)stmt->object),
782782
newowner);
783783

784784
caseOBJECT_EVENT_TRIGGER:
785-
returnAlterEventTriggerOwner(strVal(linitial(stmt->object)),
785+
returnAlterEventTriggerOwner(strVal((Value*)stmt->object),
786786
newowner);
787787

788788
caseOBJECT_PUBLICATION:
789-
returnAlterPublicationOwner(strVal(linitial(stmt->object)),
789+
returnAlterPublicationOwner(strVal((Value*)stmt->object),
790790
newowner);
791791

792792
caseOBJECT_SUBSCRIPTION:
793-
returnAlterSubscriptionOwner(strVal(linitial(stmt->object)),
793+
returnAlterSubscriptionOwner(strVal((Value*)stmt->object),
794794
newowner);
795795

796796
/* Generic cases */
@@ -814,7 +814,6 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
814814

815815
address=get_object_address(stmt->objectType,
816816
stmt->object,
817-
stmt->objarg,
818817
&relation,
819818
AccessExclusiveLock,
820819
false);

‎src/backend/commands/comment.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ CommentObject(CommentStmt *stmt)
4848
* (which is really pg_restore's fault, but for now we will work around
4949
* the problem here). Consensus is that the best fix is to treat wrong
5050
* database name as a WARNING not an ERROR; hence, the following special
51-
* case. (If the length of stmt->objname is not 1, get_object_address
52-
* will throw an error below; that's OK.)
51+
* case.
5352
*/
54-
if (stmt->objtype==OBJECT_DATABASE&&list_length(stmt->objname)==1)
53+
if (stmt->objtype==OBJECT_DATABASE)
5554
{
56-
char*database=strVal(linitial(stmt->objname));
55+
char*database=strVal((Value*)stmt->object);
5756

5857
if (!OidIsValid(get_database_oid(database, true)))
5958
{
@@ -70,12 +69,12 @@ CommentObject(CommentStmt *stmt)
7069
* does not exist, and will also acquire a lock on the target to guard
7170
* against concurrent DROP operations.
7271
*/
73-
address=get_object_address(stmt->objtype,stmt->objname,stmt->objargs,
72+
address=get_object_address(stmt->objtype,stmt->object,
7473
&relation,ShareUpdateExclusiveLock, false);
7574

7675
/* Require ownership of the target object. */
7776
check_object_ownership(GetUserId(),stmt->objtype,address,
78-
stmt->objname,stmt->objargs,relation);
77+
stmt->object,relation);
7978

8079
/* Perform other integrity checks as needed. */
8180
switch (stmt->objtype)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp