1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

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: 20150218213255.GC6717@tamriel.snowman.net
Reviewed-By: Stephen Frost, Andres Freund
This commit is contained in:
Alvaro Herrera
2015-03-03 14:10:50 -03:00
parent 6f9d799047
commit a2e35b53c3
68 changed files with 840 additions and 558 deletions

View File

@ -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);
ObjectAddressSet(address, DatabaseRelationId, db_id);
/*
* Close pg_database, but keep lock till commit.
*/
heap_close(rel, NoLock);
return db_id;
return address;
}
@ -1560,7 +1563,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
/*
* ALTER DATABASE name OWNER TO newowner
*/
Oid
ObjectAddress
AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
{
Oid db_id;
@ -1569,6 +1572,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
ScanKeyData scankey;
SysScanDesc scan;
Form_pg_database datForm;
ObjectAddress address;
/*
* Get the old tuple. We don't need a lock on the database per se,
@ -1663,12 +1667,14 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
InvokeObjectPostAlterHook(DatabaseRelationId, HeapTupleGetOid(tuple), 0);
ObjectAddressSet(address, DatabaseRelationId, db_id);
systable_endscan(scan);
/* Close pg_database, but keep lock till commit */
heap_close(rel, NoLock);
return db_id;
return address;
}