diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2015-03-16 12:06:34 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2015-03-16 12:06:34 -0300 |
commit | a61fd5334eb1040d0dcec0368702398a5b49152c (patch) | |
tree | b7976f69848c8b072cef4104208e5834ec4d93b2 /src/backend/parser | |
parent | 8d1f239003d0245dda636dfa6cf0add13bee69d6 (diff) | |
download | postgresql-a61fd5334eb1040d0dcec0368702398a5b49152c.tar.gz postgresql-a61fd5334eb1040d0dcec0368702398a5b49152c.zip |
Support opfamily members in get_object_address
In the spirit of 890192e99af and 4464303405f: have get_object_address
understand individual pg_amop and pg_amproc objects. There is no way to
refer to such objects directly in the grammar -- rather, they are almost
always considered an integral part of the opfamily that contains them.
(The only case that deals with them individually is ALTER OPERATOR
FAMILY ADD/DROP, which carries the opfamily address separately and thus
does not need it to be part of each added/dropped element's address.)
In event triggers it becomes possible to become involved with individual
amop/amproc elements, and this commit enables pg_get_object_address to
do so as well.
To make the overall coding simpler, this commit also slightly changes
the get_object_address representation for opclasses and opfamilies:
instead of having the AM name in the objargs array, I moved it as the
first element of the objnames array. This enables the new code to use
objargs for the type names used by pg_amop and pg_amproc.
Reviewed by: Stephen Frost
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/gram.y | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index cf0d31744e1..149962035dc 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -3950,8 +3950,7 @@ AlterExtensionContentsStmt: n->extname = $3; n->action = $4; n->objtype = OBJECT_OPCLASS; - n->objname = $7; - n->objargs = list_make1(makeString($9)); + n->objname = lcons(makeString($9), $7); $$ = (Node *)n; } | ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method @@ -3960,8 +3959,7 @@ AlterExtensionContentsStmt: n->extname = $3; n->action = $4; n->objtype = OBJECT_OPFAMILY; - n->objname = $7; - n->objargs = list_make1(makeString($9)); + n->objname = lcons(makeString($9), $7); $$ = (Node *)n; } | ALTER EXTENSION name add_drop SCHEMA name @@ -5362,8 +5360,7 @@ DropOpClassStmt: DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior { DropStmt *n = makeNode(DropStmt); - n->objects = list_make1($4); - n->arguments = list_make1(list_make1(makeString($6))); + n->objects = list_make1(lcons(makeString($6), $4)); n->removeType = OBJECT_OPCLASS; n->behavior = $7; n->missing_ok = false; @@ -5373,8 +5370,7 @@ DropOpClassStmt: | DROP OPERATOR CLASS IF_P EXISTS any_name USING access_method opt_drop_behavior { DropStmt *n = makeNode(DropStmt); - n->objects = list_make1($6); - n->arguments = list_make1(list_make1(makeString($8))); + n->objects = list_make1(lcons(makeString($8), $6)); n->removeType = OBJECT_OPCLASS; n->behavior = $9; n->missing_ok = true; @@ -5387,8 +5383,7 @@ DropOpFamilyStmt: DROP OPERATOR FAMILY any_name USING access_method opt_drop_behavior { DropStmt *n = makeNode(DropStmt); - n->objects = list_make1($4); - n->arguments = list_make1(list_make1(makeString($6))); + n->objects = list_make1(lcons(makeString($6), $4)); n->removeType = OBJECT_OPFAMILY; n->behavior = $7; n->missing_ok = false; @@ -5398,8 +5393,7 @@ DropOpFamilyStmt: | DROP OPERATOR FAMILY IF_P EXISTS any_name USING access_method opt_drop_behavior { DropStmt *n = makeNode(DropStmt); - n->objects = list_make1($6); - n->arguments = list_make1(list_make1(makeString($8))); + n->objects = list_make1(lcons(makeString($8), $6)); n->removeType = OBJECT_OPFAMILY; n->behavior = $9; n->missing_ok = true; @@ -5741,8 +5735,7 @@ CommentStmt: { CommentStmt *n = makeNode(CommentStmt); n->objtype = OBJECT_OPCLASS; - n->objname = $5; - n->objargs = list_make1(makeString($7)); + n->objname = lcons(makeString($7), $5); n->comment = $9; $$ = (Node *) n; } @@ -5750,8 +5743,8 @@ CommentStmt: { CommentStmt *n = makeNode(CommentStmt); n->objtype = OBJECT_OPFAMILY; - n->objname = $5; - n->objargs = list_make1(makeString($7)); + n->objname = lcons(makeString($7), $5); + n->objargs = NIL; n->comment = $9; $$ = (Node *) n; } @@ -7476,8 +7469,7 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name { RenameStmt *n = makeNode(RenameStmt); n->renameType = OBJECT_OPCLASS; - n->object = $4; - n->objarg = list_make1(makeString($6)); + n->object = lcons(makeString($6), $4); n->newname = $9; n->missing_ok = false; $$ = (Node *)n; @@ -7486,8 +7478,7 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name { RenameStmt *n = makeNode(RenameStmt); n->renameType = OBJECT_OPFAMILY; - n->object = $4; - n->objarg = list_make1(makeString($6)); + n->object = lcons(makeString($6), $4); n->newname = $9; n->missing_ok = false; $$ = (Node *)n; @@ -7924,8 +7915,7 @@ AlterObjectSchemaStmt: { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); n->objectType = OBJECT_OPCLASS; - n->object = $4; - n->objarg = list_make1(makeString($6)); + n->object = lcons(makeString($6), $4); n->newschema = $9; n->missing_ok = false; $$ = (Node *)n; @@ -7934,8 +7924,7 @@ AlterObjectSchemaStmt: { AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt); n->objectType = OBJECT_OPFAMILY; - n->object = $4; - n->objarg = list_make1(makeString($6)); + n->object = lcons(makeString($6), $4); n->newschema = $9; n->missing_ok = false; $$ = (Node *)n; @@ -8162,8 +8151,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); n->objectType = OBJECT_OPCLASS; - n->object = $4; - n->objarg = list_make1(makeString($6)); + n->object = lcons(makeString($6), $4); n->newowner = $9; $$ = (Node *)n; } @@ -8171,8 +8159,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec { AlterOwnerStmt *n = makeNode(AlterOwnerStmt); n->objectType = OBJECT_OPFAMILY; - n->object = $4; - n->objarg = list_make1(makeString($6)); + n->object = lcons(makeString($6), $4); n->newowner = $9; $$ = (Node *)n; } |