Stephen Frost wrote: > * Alvaro Herrera (alvhe...@2ndquadrant.com) wrote: > > > > Now, we probably don't want to hack *all* the utility commands to return > > > > ObjectAddress instead of OID, because it many cases that's just not > > > > going to be convenient (not to speak of the code churn); so I think for > > > > most objtypes the ProcessUtilitySlow stanza would look like this: > > > > > That'd be fine with me, though for my 2c, I wouldn't object to changing > > > them all to return ObjectAddress either. I agree that it'd cause a fair > > > bit of code churn to do so, but there's a fair bit of code churn > > > happening here anyway (looking at what 0008 does to ProcessUtilitySlow > > > anyway). > > > > Well, that would make my life easier I think (even if it's a bit more > > work), so unless there are objections I will do things this way. It's a > > bit of a pity that Robert and Dimitri went to huge lengths to have these > > functions return OID and we're now changing it all to ObjAddress > > instead, but oh well. > > Not sure that I see it as that huge a deal.. They're still returning an > Oid, it's just embedded in the ObjAddress to provide a complete > statement of what the object is.
I've been looking at this idea some more. There's some churn, but it's not that bad. For instance, here's the patch to have RENAME return ObjectAddress rather than OIDs. For instance, the get_objtype_catalog_id() function, provided in a later patch in the series, will no longer be necessary; instead, each execution code path in the src/backend/command code must set the correct catalog ID in the ObjectAddress it returns. So the event triggers code will have the catalog ID at the ready, without having to figure it out from the ObjectType it gets from the parse node. > btw, the hunk in 0026 which adds a 'break;' into standard_ProcessUtility > caught me by surprise. Looks like that 'break;' was missing from 0003 > (for T_GrantStmt). Thanks for pointing this out -- that was broken rebase. -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 69d0b62787c2a2a514f70247ccde98c4c43d70a0 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Thu, 19 Feb 2015 14:38:09 -0300 Subject: [PATCH] Have RENAME routines return ObjectAddress rather than OID This lets them include an objectSubId when appropriate (i.e. when renaming relation columns and composite type attributes), and additionally they make the catalog OID available for further processing. The object OID that was previously returned is still available in the objectId field of the returned ObjectAddress. This isn't terribly exciting in itself but it supports future event trigger changes. Discussion: 20150218213255.gc6...@tamriel.snowman.net Reviewed-By: Stephen Frost --- src/backend/catalog/dependency.c | 6 ++- src/backend/catalog/objectaddress.c | 6 +++ src/backend/commands/alter.c | 14 +++++-- src/backend/commands/dbcommands.c | 7 +++- src/backend/commands/policy.c | 7 +++- src/backend/commands/schemacmds.c | 7 +++- src/backend/commands/tablecmds.c | 77 +++++++++++++++++++++++++++++-------- src/backend/commands/tablespace.c | 7 +++- src/backend/commands/trigger.c | 7 +++- src/backend/commands/typecmds.c | 6 ++- src/backend/commands/user.c | 7 +++- src/backend/rewrite/rewriteDefine.c | 7 +++- src/include/catalog/objectaddress.h | 16 ++++++++ src/include/commands/alter.h | 3 +- src/include/commands/dbcommands.h | 3 +- src/include/commands/policy.h | 2 +- src/include/commands/schemacmds.h | 2 +- src/include/commands/tablecmds.h | 9 +++-- src/include/commands/tablespace.h | 3 +- src/include/commands/trigger.h | 3 +- src/include/commands/typecmds.h | 2 +- src/include/commands/user.h | 2 +- src/include/rewrite/rewriteDefine.h | 3 +- 23 files changed, 155 insertions(+), 51 deletions(-) diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index bacb242..25ff326 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -2269,8 +2269,9 @@ free_object_addresses(ObjectAddresses *addrs) ObjectClass getObjectClass(const ObjectAddress *object) { - /* only pg_class entries can have nonzero objectSubId */ - if (object->classId != RelationRelationId && + /* only pg_class and pg_type entries can have nonzero objectSubId */ + if ((object->classId != RelationRelationId && + object->classId != TypeRelationId) && object->objectSubId != 0) elog(ERROR, "invalid non-zero objectSubId for object class %u", object->classId); @@ -2285,6 +2286,7 @@ getObjectClass(const ObjectAddress *object) return OCLASS_PROC; case TypeRelationId: + /* caller must check objectSubId */ return OCLASS_TYPE; case CastRelationId: diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index d899dd7..2bbc15d 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -531,6 +531,12 @@ ObjectTypeMap[] = { "policy", OBJECT_POLICY } }; +ObjectAddress InvalidObjectAddress = +{ + InvalidOid, + InvalidOid, + 0 +}; static ObjectAddress get_object_address_unqualified(ObjectType objtype, List *qualname, bool missing_ok); diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c index 78b54b4..b2fb7b9 100644 --- a/src/backend/commands/alter.c +++ b/src/backend/commands/alter.c @@ -299,10 +299,14 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name) /* * Executes an ALTER OBJECT / RENAME TO statement. Based on the object * type, the function appropriate to that type is executed. + * + * Return value is the address of the renamed object. */ -Oid +ObjectAddress ExecRenameStmt(RenameStmt *stmt) { + ObjectAddress address; + switch (stmt->renameType) { case OBJECT_TABCONSTRAINT: @@ -330,9 +334,11 @@ ExecRenameStmt(RenameStmt *stmt) return RenameRelation(stmt); case OBJECT_COLUMN: - case OBJECT_ATTRIBUTE: return renameatt(stmt); + case OBJECT_ATTRIBUTE: + return renameatt_type(stmt); + case OBJECT_RULE: return RenameRewriteRule(stmt->relation, stmt->subname, stmt->newname); @@ -378,13 +384,13 @@ ExecRenameStmt(RenameStmt *stmt) stmt->newname); heap_close(catalog, RowExclusiveLock); - return address.objectId; + return address; } default: elog(ERROR, "unrecognized rename stmt type: %d", (int) stmt->renameType); - return InvalidOid; /* keep compiler happy */ + return InvalidObjectAddress; /* keep compiler happy */ } } diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 5e66961..f8dde05 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -938,7 +938,7 @@ dropdb(const char *dbname, bool missing_ok) /* * Rename database */ -Oid +ObjectAddress RenameDatabase(const char *oldname, const char *newname) { Oid db_id; @@ -946,6 +946,7 @@ RenameDatabase(const char *oldname, const char *newname) Relation rel; int notherbackends; int npreparedxacts; + ObjectAddress address; /* * Look up the target database's OID, and get exclusive lock on it. We @@ -1013,12 +1014,14 @@ RenameDatabase(const char *oldname, const char *newname) InvokeObjectPostAlterHook(DatabaseRelationId, db_id, 0); + initObjectAddress(address, DatabaseRelationId, db_id); + /* * Close pg_database, but keep lock till commit. */ heap_close(rel, NoLock); - return db_id; + return address; } diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c index d98da0d..65ecf8f 100644 --- a/src/backend/commands/policy.c +++ b/src/backend/commands/policy.c @@ -837,7 +837,7 @@ AlterPolicy(AlterPolicyStmt *stmt) * rename_policy - * change the name of a policy on a relation */ -Oid +ObjectAddress rename_policy(RenameStmt *stmt) { Relation pg_policy_rel; @@ -847,6 +847,7 @@ rename_policy(RenameStmt *stmt) ScanKeyData skey[2]; SysScanDesc sscan; HeapTuple policy_tuple; + ObjectAddress address; /* Get id of table. Also handles permissions checks. */ table_id = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock, @@ -925,6 +926,8 @@ rename_policy(RenameStmt *stmt) InvokeObjectPostAlterHook(PolicyRelationId, HeapTupleGetOid(policy_tuple), 0); + initObjectAddress(address, PolicyRelationId, opolid); + /* * Invalidate relation's relcache entry so that other backends (and * this one too!) are sent SI message to make them rebuild relcache @@ -937,7 +940,7 @@ rename_policy(RenameStmt *stmt) heap_close(pg_policy_rel, RowExclusiveLock); relation_close(target_table, NoLock); - return opoloid; + return address; } /* diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index a44dbf4..f738f48 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -195,13 +195,14 @@ RemoveSchemaById(Oid schemaOid) /* * Rename schema */ -Oid +ObjectAddress RenameSchema(const char *oldname, const char *newname) { Oid nspOid; HeapTuple tup; Relation rel; AclResult aclresult; + ObjectAddress address; rel = heap_open(NamespaceRelationId, RowExclusiveLock); @@ -243,10 +244,12 @@ RenameSchema(const char *oldname, const char *newname) InvokeObjectPostAlterHook(NamespaceRelationId, HeapTupleGetOid(tup), 0); + initObjectAddress(address, NamespaceRelationId, nspOid); + heap_close(rel, NoLock); heap_freetuple(tup); - return nspOid; + return address; } void diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 66d5083..c07a689 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -2155,8 +2155,10 @@ renameatt_check(Oid myrelid, Form_pg_class classform, bool recursing) /* * renameatt_internal - workhorse for renameatt + * + * Return value is the column number of the attribute in the 'myrelid' relation. */ -static void +static int renameatt_internal(Oid myrelid, const char *oldattname, const char *newattname, @@ -2297,6 +2299,8 @@ renameatt_internal(Oid myrelid, heap_close(attrelation, RowExclusiveLock); relation_close(targetrelation, NoLock); /* close rel but keep lock */ + + return attnum; } /* @@ -2320,10 +2324,12 @@ RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid, /* * renameatt - changes the name of a attribute in a relation */ -Oid +ObjectAddress renameatt(RenameStmt *stmt) { Oid relid; + AttrNumber attnum; + ObjectAddress address; /* lock level taken here should match renameatt_internal */ relid = RangeVarGetRelidExtended(stmt->relation, AccessExclusiveLock, @@ -2336,26 +2342,57 @@ renameatt(RenameStmt *stmt) ereport(NOTICE, (errmsg("relation \"%s\" does not exist, skipping", stmt->relation->relname))); - return InvalidOid; + return InvalidObjectAddress; } - renameatt_internal(relid, - stmt->subname, /* old att name */ - stmt->newname, /* new att name */ - interpretInhOption(stmt->relation->inhOpt), /* recursive? */ - false, /* recursing? */ - 0, /* expected inhcount */ - stmt->behavior); + attnum = + renameatt_internal(relid, + stmt->subname, /* old att name */ + stmt->newname, /* new att name */ + interpretInhOption(stmt->relation->inhOpt), /* recursive? */ + false, /* recursing? */ + 0, /* expected inhcount */ + stmt->behavior); + + initObjectAddressSub(RelationRelationId relid, attnum); /* This is an ALTER TABLE command so it's about the relid */ - return relid; + return address; } +/* + * As above, for composite types; returned ObjectAddress is that of the pg_type + * tuple, not the pg_class entry. + */ +ObjectAddress +renameatt_type(RenameStmt *stmt) +{ + HeapTuple classTup; + ObjectAddress address; + + /* + * renameatt sets the address to the pg_class object; change it to + * pg_type. + */ + address = renameatt(stmt); + + classTup = SearchSysCache1(RELOID, address.objectId); + if (!HeapTupleIsValid(classTup)) + elog(ERROR, "cache lookup failed for relation %u", address.objectId); + + /* no initObjectAddress here, to avoid objectSubId clobber */ + address.classId = TypeRelationId; + address.objectId = ((Form_pg_class) GETSTRUCT(classTup))->reltype; + + ReleaseSysCache(classTup); + + return address; +} /* * same logic as renameatt_internal */ -static Oid +static ObjectAddress rename_constraint_internal(Oid myrelid, Oid mytypid, const char *oldconname, @@ -2368,6 +2405,7 @@ rename_constraint_internal(Oid myrelid, Oid constraintOid; HeapTuple tuple; Form_pg_constraint con; + ObjectAddress address; AssertArg(!myrelid || !mytypid); @@ -2443,15 +2481,17 @@ rename_constraint_internal(Oid myrelid, else RenameConstraintById(constraintOid, newconname); + initObjectAddress(address, ConstraintRelationId, constraintOid); + ReleaseSysCache(tuple); if (targetrelation) relation_close(targetrelation, NoLock); /* close rel but keep lock */ - return constraintOid; + return address; } -Oid +ObjectAddress RenameConstraint(RenameStmt *stmt) { Oid relid = InvalidOid; @@ -2494,10 +2534,11 @@ RenameConstraint(RenameStmt *stmt) * Execute ALTER TABLE/INDEX/SEQUENCE/VIEW/MATERIALIZED VIEW/FOREIGN TABLE * RENAME */ -Oid +ObjectAddress RenameRelation(RenameStmt *stmt) { Oid relid; + ObjectAddress address = {InvalidOid, InvalidOid, 0}; /* * Grab an exclusive lock on the target table, index, sequence, view, @@ -2517,13 +2558,15 @@ RenameRelation(RenameStmt *stmt) ereport(NOTICE, (errmsg("relation \"%s\" does not exist, skipping", stmt->relation->relname))); - return InvalidOid; + return address; } /* Do the work */ RenameRelationInternal(relid, stmt->newname, false); - return relid; + initObjectAddress(RelationRelationId, relid); + + return address; } /* diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c index e098b9f..faf6197 100644 --- a/src/backend/commands/tablespace.c +++ b/src/backend/commands/tablespace.c @@ -846,7 +846,7 @@ directory_is_empty(const char *path) /* * Rename a tablespace */ -Oid +ObjectAddress RenameTableSpace(const char *oldname, const char *newname) { Oid tspId; @@ -856,6 +856,7 @@ RenameTableSpace(const char *oldname, const char *newname) HeapTuple tup; HeapTuple newtuple; Form_pg_tablespace newform; + ObjectAddress address; /* Search pg_tablespace */ rel = heap_open(TableSpaceRelationId, RowExclusiveLock); @@ -912,9 +913,11 @@ RenameTableSpace(const char *oldname, const char *newname) InvokeObjectPostAlterHook(TableSpaceRelationId, tspId, 0); + initObjectAddress(TableSpaceRelationId, tspId); + heap_close(rel, NoLock); - return tspId; + return address; } /* diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 5c1c1be..ae2ed73 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -1249,7 +1249,7 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid, * modify tgname in trigger tuple * update row in catalog */ -Oid +ObjectAddress renametrig(RenameStmt *stmt) { Oid tgoid; @@ -1259,6 +1259,7 @@ renametrig(RenameStmt *stmt) SysScanDesc tgscan; ScanKeyData key[2]; Oid relid; + ObjectAddress address; /* * Look up name, check permissions, and acquire lock (which we will NOT @@ -1351,6 +1352,8 @@ renametrig(RenameStmt *stmt) stmt->subname, RelationGetRelationName(targetrel)))); } + initObjectAddress(TriggerRelationId, tgoid); + systable_endscan(tgscan); heap_close(tgrel, RowExclusiveLock); @@ -1360,7 +1363,7 @@ renametrig(RenameStmt *stmt) */ relation_close(targetrel, NoLock); - return tgoid; + return address; } diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index b77e1b4..c786a43 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -3205,7 +3205,7 @@ GetDomainConstraints(Oid typeOid) /* * Execute ALTER TYPE RENAME */ -Oid +ObjectAddress RenameType(RenameStmt *stmt) { List *names = stmt->object; @@ -3215,6 +3215,7 @@ RenameType(RenameStmt *stmt) Relation rel; HeapTuple tup; Form_pg_type typTup; + ObjectAddress address; /* Make a TypeName so we can use standard type lookup machinery */ typename = makeTypeNameFromNameList(names); @@ -3272,10 +3273,11 @@ RenameType(RenameStmt *stmt) RenameTypeInternal(typeOid, newTypeName, typTup->typnamespace); + initObjectAddress(TypeRelationId, typeOid); /* Clean up */ heap_close(rel, RowExclusiveLock); - return typeOid; + return address; } /* diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 2210eed..0d9aa40 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -1114,7 +1114,7 @@ DropRole(DropRoleStmt *stmt) /* * Rename role */ -Oid +ObjectAddress RenameRole(const char *oldname, const char *newname) { HeapTuple oldtuple, @@ -1128,6 +1128,7 @@ RenameRole(const char *oldname, const char *newname) bool repl_repl[Natts_pg_authid]; int i; Oid roleid; + ObjectAddress address; rel = heap_open(AuthIdRelationId, RowExclusiveLock); dsc = RelationGetDescr(rel); @@ -1216,6 +1217,8 @@ RenameRole(const char *oldname, const char *newname) InvokeObjectPostAlterHook(AuthIdRelationId, roleid, 0); + initObjectAddress(AuthIdRelationId, roleid); + ReleaseSysCache(oldtuple); /* @@ -1223,7 +1226,7 @@ RenameRole(const char *oldname, const char *newname) */ heap_close(rel, NoLock); - return roleid; + return address; } /* diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index eab4d73..314fe09 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -897,7 +897,7 @@ RangeVarCallbackForRenameRule(const RangeVar *rv, Oid relid, Oid oldrelid, /* * Rename an existing rewrite rule. */ -Oid +ObjectAddress RenameRewriteRule(RangeVar *relation, const char *oldName, const char *newName) { @@ -907,6 +907,7 @@ RenameRewriteRule(RangeVar *relation, const char *oldName, HeapTuple ruletup; Form_pg_rewrite ruleform; Oid ruleOid; + ObjectAddress address; /* * Look up name, check permissions, and acquire lock (which we will NOT @@ -969,10 +970,12 @@ RenameRewriteRule(RangeVar *relation, const char *oldName, */ CacheInvalidateRelcache(targetrel); + initObjectAddress(RewriteRelationId, ruleOid); + /* * Close rel, but keep exclusive lock! */ relation_close(targetrel, NoLock); - return ruleOid; + return address; } diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h index 6f4dbab..d7298ca 100644 --- a/src/include/catalog/objectaddress.h +++ b/src/include/catalog/objectaddress.h @@ -28,6 +28,22 @@ typedef struct ObjectAddress int32 objectSubId; /* Subitem within object (eg column), or 0 */ } ObjectAddress; +extern ObjectAddress InvalidObjectAddress; + +#define initObjectAddress(addr, class_id, object_id) \ + do { \ + (addr).classId = (class_id); \ + (addr).objectId = (object_id); \ + (addr).objectSubId = 0; \ + } while (0) + +#define initObjectAddressSub(addr, class_id, object_id, object_sub_id) \ + do { \ + (addr).classId = (class_id); \ + (addr).objectId = (object_id); \ + (addr).objectSubId = (object_sub_id); \ + } while (0) + extern ObjectAddress get_object_address(ObjectType objtype, List *objname, List *objargs, Relation *relp, LOCKMODE lockmode, bool missing_ok); diff --git a/src/include/commands/alter.h b/src/include/commands/alter.h index 14d24f1..5df28d3 100644 --- a/src/include/commands/alter.h +++ b/src/include/commands/alter.h @@ -15,10 +15,11 @@ #define ALTER_H #include "catalog/dependency.h" +#include "catalog/objectaddress.h" #include "nodes/parsenodes.h" #include "utils/relcache.h" -extern Oid ExecRenameStmt(RenameStmt *stmt); +extern ObjectAddress ExecRenameStmt(RenameStmt *stmt); extern Oid ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt); extern Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid, diff --git a/src/include/commands/dbcommands.h b/src/include/commands/dbcommands.h index cb7cc0e..f3b2d09 100644 --- a/src/include/commands/dbcommands.h +++ b/src/include/commands/dbcommands.h @@ -15,6 +15,7 @@ #define DBCOMMANDS_H #include "access/xlogreader.h" +#include "catalog/objectaddress.h" #include "lib/stringinfo.h" #include "nodes/parsenodes.h" @@ -55,7 +56,7 @@ typedef struct xl_dbase_drop_rec extern Oid createdb(const CreatedbStmt *stmt); extern void dropdb(const char *dbname, bool missing_ok); -extern Oid RenameDatabase(const char *oldname, const char *newname); +extern ObjectAddress RenameDatabase(const char *oldname, const char *newname); extern Oid AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel); extern Oid AlterDatabaseSet(AlterDatabaseSetStmt *stmt); extern Oid AlterDatabaseOwner(const char *dbname, Oid newOwnerId); diff --git a/src/include/commands/policy.h b/src/include/commands/policy.h index e911fcc..2b25bae 100644 --- a/src/include/commands/policy.h +++ b/src/include/commands/policy.h @@ -28,7 +28,7 @@ extern Oid AlterPolicy(AlterPolicyStmt *stmt); extern Oid get_relation_policy_oid(Oid relid, const char *policy_name, bool missing_ok); -extern Oid rename_policy(RenameStmt *stmt); +extern ObjectAddress rename_policy(RenameStmt *stmt); #endif /* POLICY_H */ diff --git a/src/include/commands/schemacmds.h b/src/include/commands/schemacmds.h index d08fdd4..c83e003 100644 --- a/src/include/commands/schemacmds.h +++ b/src/include/commands/schemacmds.h @@ -22,7 +22,7 @@ extern Oid CreateSchemaCommand(CreateSchemaStmt *parsetree, extern void RemoveSchemaById(Oid schemaOid); -extern Oid RenameSchema(const char *oldname, const char *newname); +extern ObjectAddress RenameSchema(const char *oldname, const char *newname); extern Oid AlterSchemaOwner(const char *name, Oid newOwnerId); extern void AlterSchemaOwner_oid(Oid schemaOid, Oid newOwnerId); diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h index a55e8d4..f529337 100644 --- a/src/include/commands/tablecmds.h +++ b/src/include/commands/tablecmds.h @@ -16,6 +16,7 @@ #include "access/htup.h" #include "catalog/dependency.h" +#include "catalog/objectaddress.h" #include "nodes/parsenodes.h" #include "storage/lock.h" #include "utils/relcache.h" @@ -53,11 +54,13 @@ extern void ExecuteTruncate(TruncateStmt *stmt); extern void SetRelationHasSubclass(Oid relationId, bool relhassubclass); -extern Oid renameatt(RenameStmt *stmt); +extern ObjectAddress renameatt(RenameStmt *stmt); -extern Oid RenameConstraint(RenameStmt *stmt); +extern ObjectAddress renameatt_type(RenameStmt *stmt); -extern Oid RenameRelation(RenameStmt *stmt); +extern ObjectAddress RenameConstraint(RenameStmt *stmt); + +extern ObjectAddress RenameRelation(RenameStmt *stmt); extern void RenameRelationInternal(Oid myrelid, const char *newrelname, bool is_internal); diff --git a/src/include/commands/tablespace.h b/src/include/commands/tablespace.h index e8b9bc4..d910804 100644 --- a/src/include/commands/tablespace.h +++ b/src/include/commands/tablespace.h @@ -15,6 +15,7 @@ #define TABLESPACE_H #include "access/xlogreader.h" +#include "catalog/objectaddress.h" #include "lib/stringinfo.h" #include "nodes/parsenodes.h" @@ -42,7 +43,7 @@ typedef struct TableSpaceOpts extern Oid CreateTableSpace(CreateTableSpaceStmt *stmt); extern void DropTableSpace(DropTableSpaceStmt *stmt); -extern Oid RenameTableSpace(const char *oldname, const char *newname); +extern ObjectAddress RenameTableSpace(const char *oldname, const char *newname); extern Oid AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt); extern void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo); diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h index d0c0dcc..e09ac29 100644 --- a/src/include/commands/trigger.h +++ b/src/include/commands/trigger.h @@ -13,6 +13,7 @@ #ifndef TRIGGER_H #define TRIGGER_H +#include "catalog/objectaddress.h" #include "nodes/execnodes.h" #include "nodes/parsenodes.h" @@ -115,7 +116,7 @@ extern Oid CreateTrigger(CreateTrigStmt *stmt, const char *queryString, extern void RemoveTriggerById(Oid trigOid); extern Oid get_trigger_oid(Oid relid, const char *name, bool missing_ok); -extern Oid renametrig(RenameStmt *stmt); +extern ObjectAddress renametrig(RenameStmt *stmt); extern void EnableDisableTrigger(Relation rel, const char *tgname, char fires_when, bool skip_system); diff --git a/src/include/commands/typecmds.h b/src/include/commands/typecmds.h index e18a714..daeabfe 100644 --- a/src/include/commands/typecmds.h +++ b/src/include/commands/typecmds.h @@ -41,7 +41,7 @@ extern void checkDomainOwner(HeapTuple tup); extern List *GetDomainConstraints(Oid typeOid); -extern Oid RenameType(RenameStmt *stmt); +extern ObjectAddress RenameType(RenameStmt *stmt); extern Oid AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype); extern void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId, bool hasDependEntry); diff --git a/src/include/commands/user.h b/src/include/commands/user.h index d766851..ab10138 100644 --- a/src/include/commands/user.h +++ b/src/include/commands/user.h @@ -27,7 +27,7 @@ extern Oid AlterRole(AlterRoleStmt *stmt); extern Oid AlterRoleSet(AlterRoleSetStmt *stmt); extern void DropRole(DropRoleStmt *stmt); extern void GrantRole(GrantRoleStmt *stmt); -extern Oid RenameRole(const char *oldname, const char *newname); +extern ObjectAddress RenameRole(const char *oldname, const char *newname); extern void DropOwnedObjects(DropOwnedStmt *stmt); extern void ReassignOwnedObjects(ReassignOwnedStmt *stmt); extern List *roleNamesToIds(List *memberNames); diff --git a/src/include/rewrite/rewriteDefine.h b/src/include/rewrite/rewriteDefine.h index d384552..c112b85 100644 --- a/src/include/rewrite/rewriteDefine.h +++ b/src/include/rewrite/rewriteDefine.h @@ -14,6 +14,7 @@ #ifndef REWRITEDEFINE_H #define REWRITEDEFINE_H +#include "catalog/objectaddress.h" #include "nodes/parsenodes.h" #include "utils/relcache.h" @@ -32,7 +33,7 @@ extern Oid DefineQueryRewrite(char *rulename, bool replace, List *action); -extern Oid RenameRewriteRule(RangeVar *relation, const char *oldName, +extern ObjectAddress RenameRewriteRule(RangeVar *relation, const char *oldName, const char *newName); extern void setRuleCheckAsUser(Node *node, Oid userid); -- 2.1.4
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers