diff options
author | Alvaro Herrera | 2015-03-03 17:10:50 +0000 |
---|---|---|
committer | Alvaro Herrera | 2015-03-03 17:10:50 +0000 |
commit | a2e35b53c39b2a27d3e332dc7c506539c306fd44 (patch) | |
tree | 1f4cd33208d33f4a8b3159b0d3757109c67d4b14 /src/backend/tcop/utility.c | |
parent | 6f9d79904748c26a58991942dc6719db558f77b0 (diff) |
Change many routines to return ObjectAddress rather than OID
The changed routines are mostly those that can be directly called by
ProcessUtilitySlow; the intention is to make the affected object
information more precise, in support for future event trigger changes.
Originally it was envisioned that the OID of the affected object would
be enough, and in most cases that is correct, but upon actually
implementing the event trigger changes it turned out that ObjectAddress
is more widely useful.
Additionally, some command execution routines grew an output argument
that's an object address which provides further info about the executed
command. To wit:
* for ALTER DOMAIN / ADD CONSTRAINT, it corresponds to the address of
the new constraint
* for ALTER OBJECT / SET SCHEMA, it corresponds to the address of the
schema that originally contained the object.
* for ALTER EXTENSION {ADD, DROP} OBJECT, it corresponds to the address
of the object added to or dropped from the extension.
There's no user-visible change in this commit, and no functional change
either.
Discussion: [email protected]
Reviewed-By: Stephen Frost, Andres Freund
Diffstat (limited to 'src/backend/tcop/utility.c')
-rw-r--r-- | src/backend/tcop/utility.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 6d269865e7e..daf532693c2 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -818,7 +818,7 @@ standard_ProcessUtility(Node *parsetree, context, params, dest, completionTag); else - ExecAlterObjectSchemaStmt(stmt); + ExecAlterObjectSchemaStmt(stmt, NULL); } break; @@ -886,6 +886,7 @@ ProcessUtilitySlow(Node *parsetree, bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL); bool isCompleteQuery = (context <= PROCESS_UTILITY_QUERY); bool needCleanup; + ObjectAddress address; /* All event trigger calls are done only when isCompleteQuery is true */ needCleanup = isCompleteQuery && EventTriggerBeginCompleteQuery(); @@ -911,7 +912,6 @@ ProcessUtilitySlow(Node *parsetree, { List *stmts; ListCell *l; - Oid relOid; /* Run parse analysis ... */ stmts = transformCreateStmt((CreateStmt *) parsetree, @@ -928,9 +928,9 @@ ProcessUtilitySlow(Node *parsetree, static char *validnsps[] = HEAP_RELOPT_NAMESPACES; /* Create the table itself */ - relOid = DefineRelation((CreateStmt *) stmt, - RELKIND_RELATION, - InvalidOid); + address = DefineRelation((CreateStmt *) stmt, + RELKIND_RELATION, + InvalidOid, NULL); /* * Let NewRelationCreateToastTable decide if this @@ -952,16 +952,17 @@ ProcessUtilitySlow(Node *parsetree, toast_options, true); - NewRelationCreateToastTable(relOid, toast_options); + NewRelationCreateToastTable(address.objectId, + toast_options); } else if (IsA(stmt, CreateForeignTableStmt)) { /* Create the table itself */ - relOid = DefineRelation((CreateStmt *) stmt, - RELKIND_FOREIGN_TABLE, - InvalidOid); + address = DefineRelation((CreateStmt *) stmt, + RELKIND_FOREIGN_TABLE, + InvalidOid, NULL); CreateForeignTable((CreateForeignTableStmt *) stmt, - relOid); + address.objectId); } else { @@ -1067,7 +1068,8 @@ ProcessUtilitySlow(Node *parsetree, break; case 'C': /* ADD CONSTRAINT */ AlterDomainAddConstraint(stmt->typeName, - stmt->def); + stmt->def, + NULL); break; case 'X': /* DROP CONSTRAINT */ AlterDomainDropConstraint(stmt->typeName, @@ -1190,7 +1192,8 @@ ProcessUtilitySlow(Node *parsetree, break; case T_AlterExtensionContentsStmt: - ExecAlterExtensionContentsStmt((AlterExtensionContentsStmt *) parsetree); + ExecAlterExtensionContentsStmt((AlterExtensionContentsStmt *) parsetree, + NULL); break; case T_CreateFdwStmt: @@ -1334,7 +1337,8 @@ ProcessUtilitySlow(Node *parsetree, break; case T_AlterObjectSchemaStmt: - ExecAlterObjectSchemaStmt((AlterObjectSchemaStmt *) parsetree); + ExecAlterObjectSchemaStmt((AlterObjectSchemaStmt *) parsetree, + NULL); break; case T_AlterOwnerStmt: |