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

Adjust more backend functions to return OID rather than void.

This is again intended to support extensions to the event trigger
functionality.  This may go a bit further than we need for that
purpose, but there's some value in being consistent, and the OID
may be useful for other purposes also.

Dimitri Fontaine
This commit is contained in:
Robert Haas
2012-12-29 07:55:37 -05:00
parent 5ab3af46dd
commit 82b1b213ca
29 changed files with 231 additions and 131 deletions

View File

@ -90,7 +90,7 @@ static int errdetail_busy_db(int notherbackends, int npreparedxacts);
/*
* CREATE DATABASE
*/
void
Oid
createdb(const CreatedbStmt *stmt)
{
HeapScanDesc scan;
@ -655,6 +655,8 @@ createdb(const CreatedbStmt *stmt)
}
PG_END_ENSURE_ERROR_CLEANUP(createdb_failure_callback,
PointerGetDatum(&fparms));
return dboid;
}
/*
@ -1301,10 +1303,11 @@ movedb_failure_callback(int code, Datum arg)
/*
* ALTER DATABASE name ...
*/
void
Oid
AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
{
Relation rel;
Oid dboid;
HeapTuple tuple,
newtuple;
ScanKeyData scankey;
@ -1350,7 +1353,7 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
/* this case isn't allowed within a transaction block */
PreventTransactionChain(isTopLevel, "ALTER DATABASE SET TABLESPACE");
movedb(stmt->dbname, strVal(dtablespace->arg));
return;
return InvalidOid;
}
if (dconnlimit)
@ -1380,6 +1383,8 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", stmt->dbname)));
dboid = HeapTupleGetOid(tuple);
if (!pg_database_ownercheck(HeapTupleGetOid(tuple), GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
stmt->dbname);
@ -1408,13 +1413,15 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
/* Close pg_database, but keep lock till commit */
heap_close(rel, NoLock);
return dboid;
}
/*
* ALTER DATABASE name SET ...
*/
void
Oid
AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
{
Oid datid = get_database_oid(stmt->dbname, false);
@ -1432,6 +1439,8 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
AlterSetting(datid, InvalidOid, stmt->setstmt);
UnlockSharedObject(DatabaseRelationId, datid, 0, AccessShareLock);
return datid;
}