mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Adjust many backend functions to return OID rather than void.
Extracted from a larger patch by Dimitri Fontaine. It is hoped that this will provide infrastructure for enriching the new event trigger functionality, but it seems possibly useful for other purposes as well.
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
* is specified by a BASETYPE element in the parameters. Otherwise,
|
||||
* "args" defines the input type(s).
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
|
||||
{
|
||||
char *aggName;
|
||||
@@ -216,15 +216,15 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
|
||||
/*
|
||||
* Most of the argument-checking is done inside of AggregateCreate
|
||||
*/
|
||||
AggregateCreate(aggName, /* aggregate name */
|
||||
aggNamespace, /* namespace */
|
||||
aggArgTypes, /* input data type(s) */
|
||||
numArgs,
|
||||
transfuncName, /* step function name */
|
||||
finalfuncName, /* final function name */
|
||||
sortoperatorName, /* sort operator name */
|
||||
transTypeId, /* transition data type */
|
||||
initval); /* initial condition */
|
||||
return AggregateCreate(aggName, /* aggregate name */
|
||||
aggNamespace, /* namespace */
|
||||
aggArgTypes, /* input data type(s) */
|
||||
numArgs,
|
||||
transfuncName, /* step function name */
|
||||
finalfuncName, /* final function name */
|
||||
sortoperatorName, /* sort operator name */
|
||||
transTypeId, /* transition data type */
|
||||
initval); /* initial condition */
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ DefineAggregate(List *name, List *args, bool oldstyle, List *parameters)
|
||||
* RenameAggregate
|
||||
* Rename an aggregate.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameAggregate(List *name, List *args, const char *newname)
|
||||
{
|
||||
Oid procOid;
|
||||
@@ -286,4 +286,6 @@ RenameAggregate(List *name, List *args, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return procOid;
|
||||
}
|
||||
|
@@ -50,112 +50,90 @@
|
||||
* Executes an ALTER OBJECT / RENAME TO statement. Based on the object
|
||||
* type, the function appropriate to that type is executed.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
ExecRenameStmt(RenameStmt *stmt)
|
||||
{
|
||||
switch (stmt->renameType)
|
||||
{
|
||||
case OBJECT_AGGREGATE:
|
||||
RenameAggregate(stmt->object, stmt->objarg, stmt->newname);
|
||||
break;
|
||||
return RenameAggregate(stmt->object, stmt->objarg, stmt->newname);
|
||||
|
||||
case OBJECT_COLLATION:
|
||||
RenameCollation(stmt->object, stmt->newname);
|
||||
break;
|
||||
return RenameCollation(stmt->object, stmt->newname);
|
||||
|
||||
case OBJECT_CONSTRAINT:
|
||||
RenameConstraint(stmt);
|
||||
break;
|
||||
return RenameConstraint(stmt);
|
||||
|
||||
case OBJECT_CONVERSION:
|
||||
RenameConversion(stmt->object, stmt->newname);
|
||||
break;
|
||||
return RenameConversion(stmt->object, stmt->newname);
|
||||
|
||||
case OBJECT_DATABASE:
|
||||
RenameDatabase(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameDatabase(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_FDW:
|
||||
RenameForeignDataWrapper(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameForeignDataWrapper(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_FOREIGN_SERVER:
|
||||
RenameForeignServer(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameForeignServer(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_EVENT_TRIGGER:
|
||||
RenameEventTrigger(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameEventTrigger(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_FUNCTION:
|
||||
RenameFunction(stmt->object, stmt->objarg, stmt->newname);
|
||||
break;
|
||||
return RenameFunction(stmt->object, stmt->objarg, stmt->newname);
|
||||
|
||||
case OBJECT_LANGUAGE:
|
||||
RenameLanguage(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameLanguage(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_OPCLASS:
|
||||
RenameOpClass(stmt->object, stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameOpClass(stmt->object, stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_OPFAMILY:
|
||||
RenameOpFamily(stmt->object, stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameOpFamily(stmt->object, stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_ROLE:
|
||||
RenameRole(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameRole(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_SCHEMA:
|
||||
RenameSchema(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameSchema(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_TABLESPACE:
|
||||
RenameTableSpace(stmt->subname, stmt->newname);
|
||||
break;
|
||||
return RenameTableSpace(stmt->subname, stmt->newname);
|
||||
|
||||
case OBJECT_TABLE:
|
||||
case OBJECT_SEQUENCE:
|
||||
case OBJECT_VIEW:
|
||||
case OBJECT_INDEX:
|
||||
case OBJECT_FOREIGN_TABLE:
|
||||
RenameRelation(stmt);
|
||||
break;
|
||||
return RenameRelation(stmt);
|
||||
|
||||
case OBJECT_COLUMN:
|
||||
case OBJECT_ATTRIBUTE:
|
||||
renameatt(stmt);
|
||||
break;
|
||||
return renameatt(stmt);
|
||||
|
||||
case OBJECT_TRIGGER:
|
||||
renametrig(stmt);
|
||||
break;
|
||||
return renametrig(stmt);
|
||||
|
||||
case OBJECT_TSPARSER:
|
||||
RenameTSParser(stmt->object, stmt->newname);
|
||||
break;
|
||||
return RenameTSParser(stmt->object, stmt->newname);
|
||||
|
||||
case OBJECT_TSDICTIONARY:
|
||||
RenameTSDictionary(stmt->object, stmt->newname);
|
||||
break;
|
||||
return RenameTSDictionary(stmt->object, stmt->newname);
|
||||
|
||||
case OBJECT_TSTEMPLATE:
|
||||
RenameTSTemplate(stmt->object, stmt->newname);
|
||||
break;
|
||||
return RenameTSTemplate(stmt->object, stmt->newname);
|
||||
|
||||
case OBJECT_TSCONFIGURATION:
|
||||
RenameTSConfiguration(stmt->object, stmt->newname);
|
||||
break;
|
||||
return RenameTSConfiguration(stmt->object, stmt->newname);
|
||||
|
||||
case OBJECT_DOMAIN:
|
||||
case OBJECT_TYPE:
|
||||
RenameType(stmt);
|
||||
break;
|
||||
return RenameType(stmt);
|
||||
|
||||
default:
|
||||
elog(ERROR, "unrecognized rename stmt type: %d",
|
||||
(int) stmt->renameType);
|
||||
return InvalidOid; /* keep compiler happy */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,40 +141,35 @@ ExecRenameStmt(RenameStmt *stmt)
|
||||
* Executes an ALTER OBJECT / SET SCHEMA statement. Based on the object
|
||||
* type, the function appropriate to that type is executed.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
|
||||
{
|
||||
switch (stmt->objectType)
|
||||
{
|
||||
case OBJECT_AGGREGATE:
|
||||
AlterFunctionNamespace(stmt->object, stmt->objarg, true,
|
||||
stmt->newschema);
|
||||
break;
|
||||
return AlterFunctionNamespace(stmt->object, stmt->objarg, true,
|
||||
stmt->newschema);
|
||||
|
||||
case OBJECT_COLLATION:
|
||||
AlterCollationNamespace(stmt->object, stmt->newschema);
|
||||
break;
|
||||
return AlterCollationNamespace(stmt->object, stmt->newschema);
|
||||
|
||||
case OBJECT_EXTENSION:
|
||||
AlterExtensionNamespace(stmt->object, stmt->newschema);
|
||||
break;
|
||||
return AlterExtensionNamespace(stmt->object, stmt->newschema);
|
||||
|
||||
case OBJECT_FUNCTION:
|
||||
AlterFunctionNamespace(stmt->object, stmt->objarg, false,
|
||||
stmt->newschema);
|
||||
break;
|
||||
return AlterFunctionNamespace(stmt->object, stmt->objarg, false,
|
||||
stmt->newschema);
|
||||
|
||||
case OBJECT_SEQUENCE:
|
||||
case OBJECT_TABLE:
|
||||
case OBJECT_VIEW:
|
||||
case OBJECT_FOREIGN_TABLE:
|
||||
AlterTableNamespace(stmt);
|
||||
break;
|
||||
return AlterTableNamespace(stmt);
|
||||
|
||||
case OBJECT_TYPE:
|
||||
case OBJECT_DOMAIN:
|
||||
AlterTypeNamespace(stmt->object, stmt->newschema, stmt->objectType);
|
||||
break;
|
||||
return AlterTypeNamespace(stmt->object, stmt->newschema,
|
||||
stmt->objectType);
|
||||
|
||||
/* generic code path */
|
||||
case OBJECT_CONVERSION:
|
||||
@@ -228,12 +201,15 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt)
|
||||
AlterObjectNamespace_internal(catalog, address.objectId,
|
||||
nspOid);
|
||||
heap_close(catalog, RowExclusiveLock);
|
||||
|
||||
return address.objectId;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "unrecognized AlterObjectSchemaStmt type: %d",
|
||||
(int) stmt->objectType);
|
||||
return InvalidOid; /* keep compiler happy */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,7 +411,7 @@ AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
|
||||
* Executes an ALTER OBJECT / OWNER TO statement. Based on the object
|
||||
* type, the function appropriate to that type is executed.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
|
||||
{
|
||||
Oid newowner = get_role_oid(stmt->newowner, false);
|
||||
@@ -443,30 +419,27 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
|
||||
switch (stmt->objectType)
|
||||
{
|
||||
case OBJECT_DATABASE:
|
||||
AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner);
|
||||
break;
|
||||
return AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner);
|
||||
|
||||
case OBJECT_SCHEMA:
|
||||
AlterSchemaOwner(strVal(linitial(stmt->object)), newowner);
|
||||
break;
|
||||
return AlterSchemaOwner(strVal(linitial(stmt->object)), newowner);
|
||||
|
||||
case OBJECT_TYPE:
|
||||
case OBJECT_DOMAIN: /* same as TYPE */
|
||||
AlterTypeOwner(stmt->object, newowner, stmt->objectType);
|
||||
return AlterTypeOwner(stmt->object, newowner, stmt->objectType);
|
||||
break;
|
||||
|
||||
case OBJECT_FDW:
|
||||
AlterForeignDataWrapperOwner(strVal(linitial(stmt->object)),
|
||||
newowner);
|
||||
break;
|
||||
return AlterForeignDataWrapperOwner(strVal(linitial(stmt->object)),
|
||||
newowner);
|
||||
|
||||
case OBJECT_FOREIGN_SERVER:
|
||||
AlterForeignServerOwner(strVal(linitial(stmt->object)), newowner);
|
||||
break;
|
||||
return AlterForeignServerOwner(strVal(linitial(stmt->object)),
|
||||
newowner);
|
||||
|
||||
case OBJECT_EVENT_TRIGGER:
|
||||
AlterEventTriggerOwner(strVal(linitial(stmt->object)), newowner);
|
||||
break;
|
||||
return AlterEventTriggerOwner(strVal(linitial(stmt->object)),
|
||||
newowner);
|
||||
|
||||
/* Generic cases */
|
||||
case OBJECT_AGGREGATE:
|
||||
@@ -508,12 +481,16 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
|
||||
|
||||
AlterObjectOwner_internal(catalog, address.objectId, newowner);
|
||||
heap_close(catalog, RowExclusiveLock);
|
||||
|
||||
return address.objectId;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(ERROR, "unrecognized AlterOwnerStmt type: %d",
|
||||
(int) stmt->objectType);
|
||||
|
||||
return InvalidOid; /* keep compiler happy */
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -37,7 +37,7 @@
|
||||
/*
|
||||
* CREATE COLLATION
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineCollation(List *names, List *parameters)
|
||||
{
|
||||
char *collName;
|
||||
@@ -140,12 +140,14 @@ DefineCollation(List *names, List *parameters)
|
||||
/* check that the locales can be loaded */
|
||||
CommandCounterIncrement();
|
||||
(void) pg_newlocale_from_collation(newoid);
|
||||
|
||||
return newoid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename collation
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameCollation(List *name, const char *newname)
|
||||
{
|
||||
Oid collationOid;
|
||||
@@ -206,12 +208,14 @@ RenameCollation(List *name, const char *newname)
|
||||
heap_freetuple(tup);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return collationOid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute ALTER COLLATION SET SCHEMA
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterCollationNamespace(List *name, const char *newschema)
|
||||
{
|
||||
Oid collOid,
|
||||
@@ -222,6 +226,8 @@ AlterCollationNamespace(List *name, const char *newschema)
|
||||
nspOid = LookupCreationNamespace(newschema);
|
||||
|
||||
AlterCollationNamespace_oid(collOid, nspOid);
|
||||
|
||||
return collOid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -34,7 +34,7 @@
|
||||
/*
|
||||
* CREATE CONVERSION
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
CreateConversionCommand(CreateConversionStmt *stmt)
|
||||
{
|
||||
Oid namespaceId;
|
||||
@@ -111,14 +111,14 @@ CreateConversionCommand(CreateConversionStmt *stmt)
|
||||
* All seem ok, go ahead (possible failure would be a duplicate conversion
|
||||
* name)
|
||||
*/
|
||||
ConversionCreate(conversion_name, namespaceId, GetUserId(),
|
||||
from_encoding, to_encoding, funcoid, stmt->def);
|
||||
return ConversionCreate(conversion_name, namespaceId, GetUserId(),
|
||||
from_encoding, to_encoding, funcoid, stmt->def);
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename conversion
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameConversion(List *name, const char *newname)
|
||||
{
|
||||
Oid conversionOid;
|
||||
@@ -164,4 +164,6 @@ RenameConversion(List *name, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return conversionOid;
|
||||
}
|
||||
|
@@ -900,7 +900,7 @@ dropdb(const char *dbname, bool missing_ok)
|
||||
/*
|
||||
* Rename database
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameDatabase(const char *oldname, const char *newname)
|
||||
{
|
||||
Oid db_id;
|
||||
@@ -977,6 +977,8 @@ RenameDatabase(const char *oldname, const char *newname)
|
||||
* Close pg_database, but keep lock till commit.
|
||||
*/
|
||||
heap_close(rel, NoLock);
|
||||
|
||||
return db_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -1436,9 +1438,10 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
|
||||
/*
|
||||
* ALTER DATABASE name OWNER TO newowner
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
|
||||
{
|
||||
Oid db_id;
|
||||
HeapTuple tuple;
|
||||
Relation rel;
|
||||
ScanKeyData scankey;
|
||||
@@ -1463,6 +1466,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
|
||||
(errcode(ERRCODE_UNDEFINED_DATABASE),
|
||||
errmsg("database \"%s\" does not exist", dbname)));
|
||||
|
||||
db_id = HeapTupleGetOid(tuple);
|
||||
datForm = (Form_pg_database) GETSTRUCT(tuple);
|
||||
|
||||
/*
|
||||
@@ -1539,6 +1543,8 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
|
||||
|
||||
/* Close pg_database, but keep lock till commit */
|
||||
heap_close(rel, NoLock);
|
||||
|
||||
return db_id;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -413,9 +413,10 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
|
||||
/*
|
||||
* Rename event trigger
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameEventTrigger(const char *trigname, const char *newname)
|
||||
{
|
||||
Oid evtId;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
Form_pg_event_trigger evtForm;
|
||||
@@ -438,6 +439,8 @@ RenameEventTrigger(const char *trigname, const char *newname)
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_EVENT_TRIGGER,
|
||||
trigname);
|
||||
|
||||
evtId = HeapTupleGetOid(tup);
|
||||
|
||||
evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
|
||||
|
||||
/* tuple is a copy, so we can rename it now */
|
||||
@@ -447,15 +450,18 @@ RenameEventTrigger(const char *trigname, const char *newname)
|
||||
|
||||
heap_freetuple(tup);
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return evtId;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Change event trigger's owner -- by name
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterEventTriggerOwner(const char *name, Oid newOwnerId)
|
||||
{
|
||||
Oid evtOid;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
@@ -468,11 +474,15 @@ AlterEventTriggerOwner(const char *name, Oid newOwnerId)
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("event trigger \"%s\" does not exist", name)));
|
||||
|
||||
evtOid = HeapTupleGetOid(tup);
|
||||
|
||||
AlterEventTriggerOwner_internal(rel, tup, newOwnerId);
|
||||
|
||||
heap_freetuple(tup);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return evtOid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1174,7 +1174,7 @@ find_update_path(List *evi_list,
|
||||
/*
|
||||
* CREATE EXTENSION
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
CreateExtension(CreateExtensionStmt *stmt)
|
||||
{
|
||||
DefElem *d_schema = NULL;
|
||||
@@ -1210,7 +1210,7 @@ CreateExtension(CreateExtensionStmt *stmt)
|
||||
(errcode(ERRCODE_DUPLICATE_OBJECT),
|
||||
errmsg("extension \"%s\" already exists, skipping",
|
||||
stmt->extname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
else
|
||||
ereport(ERROR,
|
||||
@@ -1470,6 +1470,8 @@ CreateExtension(CreateExtensionStmt *stmt)
|
||||
*/
|
||||
ApplyExtensionUpdates(extensionOid, pcontrol,
|
||||
versionName, updateVersions);
|
||||
|
||||
return extensionOid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2398,7 +2400,7 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
|
||||
/*
|
||||
* Execute ALTER EXTENSION SET SCHEMA
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterExtensionNamespace(List *names, const char *newschema)
|
||||
{
|
||||
char *extensionName;
|
||||
@@ -2479,7 +2481,7 @@ AlterExtensionNamespace(List *names, const char *newschema)
|
||||
if (extForm->extnamespace == nspOid)
|
||||
{
|
||||
heap_close(extRel, RowExclusiveLock);
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
/* Check extension is supposed to be relocatable */
|
||||
@@ -2571,6 +2573,8 @@ AlterExtensionNamespace(List *names, const char *newschema)
|
||||
/* update dependencies to point to the new schema */
|
||||
changeDependencyFor(ExtensionRelationId, extensionOid,
|
||||
NamespaceRelationId, oldNspOid, nspOid);
|
||||
|
||||
return extensionOid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -204,9 +204,10 @@ GetUserOidFromMapping(const char *username, bool missing_ok)
|
||||
/*
|
||||
* Rename foreign-data wrapper
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameForeignDataWrapper(const char *oldname, const char *newname)
|
||||
{
|
||||
Oid fdwId;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
@@ -218,6 +219,8 @@ RenameForeignDataWrapper(const char *oldname, const char *newname)
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("foreign-data wrapper \"%s\" does not exist", oldname)));
|
||||
|
||||
fdwId = HeapTupleGetOid(tup);
|
||||
|
||||
/* make sure the new name doesn't exist */
|
||||
if (SearchSysCacheExists1(FOREIGNDATAWRAPPERNAME, CStringGetDatum(newname)))
|
||||
ereport(ERROR,
|
||||
@@ -236,15 +239,18 @@ RenameForeignDataWrapper(const char *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return fdwId;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Rename foreign server
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameForeignServer(const char *oldname, const char *newname)
|
||||
{
|
||||
Oid srvId;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
@@ -256,6 +262,8 @@ RenameForeignServer(const char *oldname, const char *newname)
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("server \"%s\" does not exist", oldname)));
|
||||
|
||||
srvId = HeapTupleGetOid(tup);
|
||||
|
||||
/* make sure the new name doesn't exist */
|
||||
if (SearchSysCacheExists1(FOREIGNSERVERNAME, CStringGetDatum(newname)))
|
||||
ereport(ERROR,
|
||||
@@ -274,6 +282,8 @@ RenameForeignServer(const char *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return srvId;
|
||||
}
|
||||
|
||||
|
||||
@@ -325,9 +335,10 @@ AlterForeignDataWrapperOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerI
|
||||
*
|
||||
* Note restrictions in the "_internal" function, above.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
|
||||
{
|
||||
Oid fdwId;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
@@ -340,11 +351,15 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("foreign-data wrapper \"%s\" does not exist", name)));
|
||||
|
||||
fdwId = HeapTupleGetOid(tup);
|
||||
|
||||
AlterForeignDataWrapperOwner_internal(rel, tup, newOwnerId);
|
||||
|
||||
heap_freetuple(tup);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return fdwId;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -426,9 +441,10 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
/*
|
||||
* Change foreign server owner -- by name
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterForeignServerOwner(const char *name, Oid newOwnerId)
|
||||
{
|
||||
Oid servOid;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
@@ -441,11 +457,15 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("server \"%s\" does not exist", name)));
|
||||
|
||||
servOid = HeapTupleGetOid(tup);
|
||||
|
||||
AlterForeignServerOwner_internal(rel, tup, newOwnerId);
|
||||
|
||||
heap_freetuple(tup);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return servOid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -784,7 +784,7 @@ interpret_AS_clause(Oid languageOid, const char *languageName,
|
||||
* CreateFunction
|
||||
* Execute a CREATE FUNCTION utility statement.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
|
||||
{
|
||||
char *probin_str;
|
||||
@@ -960,30 +960,30 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
|
||||
* And now that we have all the parameters, and know we're permitted to do
|
||||
* so, go ahead and create the function.
|
||||
*/
|
||||
ProcedureCreate(funcname,
|
||||
namespaceId,
|
||||
stmt->replace,
|
||||
returnsSet,
|
||||
prorettype,
|
||||
GetUserId(),
|
||||
languageOid,
|
||||
languageValidator,
|
||||
prosrc_str, /* converted to text later */
|
||||
probin_str, /* converted to text later */
|
||||
false, /* not an aggregate */
|
||||
isWindowFunc,
|
||||
security,
|
||||
isLeakProof,
|
||||
isStrict,
|
||||
volatility,
|
||||
parameterTypes,
|
||||
PointerGetDatum(allParameterTypes),
|
||||
PointerGetDatum(parameterModes),
|
||||
PointerGetDatum(parameterNames),
|
||||
parameterDefaults,
|
||||
PointerGetDatum(proconfig),
|
||||
procost,
|
||||
prorows);
|
||||
return ProcedureCreate(funcname,
|
||||
namespaceId,
|
||||
stmt->replace,
|
||||
returnsSet,
|
||||
prorettype,
|
||||
GetUserId(),
|
||||
languageOid,
|
||||
languageValidator,
|
||||
prosrc_str, /* converted to text later */
|
||||
probin_str, /* converted to text later */
|
||||
false, /* not an aggregate */
|
||||
isWindowFunc,
|
||||
security,
|
||||
isLeakProof,
|
||||
isStrict,
|
||||
volatility,
|
||||
parameterTypes,
|
||||
PointerGetDatum(allParameterTypes),
|
||||
PointerGetDatum(parameterModes),
|
||||
PointerGetDatum(parameterNames),
|
||||
parameterDefaults,
|
||||
PointerGetDatum(proconfig),
|
||||
procost,
|
||||
prorows);
|
||||
}
|
||||
|
||||
|
||||
@@ -1040,7 +1040,7 @@ RemoveFunctionById(Oid funcOid)
|
||||
/*
|
||||
* Rename function
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameFunction(List *name, List *argtypes, const char *newname)
|
||||
{
|
||||
Oid procOid;
|
||||
@@ -1102,6 +1102,8 @@ RenameFunction(List *name, List *argtypes, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return procOid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1686,7 +1688,7 @@ DropCastById(Oid castOid)
|
||||
*
|
||||
* These commands are identical except for the lookup procedure, so share code.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
|
||||
const char *newschema)
|
||||
{
|
||||
@@ -1703,6 +1705,8 @@ AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
|
||||
nspOid = LookupCreationNamespace(newschema);
|
||||
|
||||
AlterFunctionNamespace_oid(procOid, nspOid);
|
||||
|
||||
return procOid;
|
||||
}
|
||||
|
||||
Oid
|
||||
|
@@ -1660,7 +1660,7 @@ RemoveAmProcEntryById(Oid entryOid)
|
||||
/*
|
||||
* Rename opclass
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameOpClass(List *name, const char *access_method, const char *newname)
|
||||
{
|
||||
Oid opcOid;
|
||||
@@ -1713,12 +1713,14 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return opcOid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename opfamily
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameOpFamily(List *name, const char *access_method, const char *newname)
|
||||
{
|
||||
Oid opfOid;
|
||||
@@ -1802,6 +1804,8 @@ RenameOpFamily(List *name, const char *access_method, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return opfOid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -59,7 +59,7 @@
|
||||
*
|
||||
* 'parameters' is a list of DefElem
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineOperator(List *names, List *parameters)
|
||||
{
|
||||
char *oprName;
|
||||
@@ -295,20 +295,20 @@ DefineOperator(List *names, List *parameters)
|
||||
/*
|
||||
* now have OperatorCreate do all the work..
|
||||
*/
|
||||
OperatorCreate(oprName, /* operator name */
|
||||
oprNamespace, /* namespace */
|
||||
typeId1, /* left type id */
|
||||
typeId2, /* right type id */
|
||||
functionOid, /* function for operator */
|
||||
commutatorName, /* optional commutator operator name */
|
||||
negatorName, /* optional negator operator name */
|
||||
restrictionOid, /* optional restrict. sel. procedure */
|
||||
joinOid, /* optional join sel. procedure name */
|
||||
canMerge, /* operator merges */
|
||||
canHash); /* operator hashes */
|
||||
return
|
||||
OperatorCreate(oprName, /* operator name */
|
||||
oprNamespace, /* namespace */
|
||||
typeId1, /* left type id */
|
||||
typeId2, /* right type id */
|
||||
functionOid, /* function for operator */
|
||||
commutatorName, /* optional commutator operator name */
|
||||
negatorName, /* optional negator operator name */
|
||||
restrictionOid, /* optional restrict. sel. procedure */
|
||||
joinOid, /* optional join sel. procedure name */
|
||||
canMerge, /* operator merges */
|
||||
canHash); /* operator hashes */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Guts of operator deletion.
|
||||
*/
|
||||
|
@@ -537,9 +537,10 @@ DropProceduralLanguageById(Oid langOid)
|
||||
/*
|
||||
* Rename language
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameLanguage(const char *oldname, const char *newname)
|
||||
{
|
||||
Oid lanId;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
@@ -551,6 +552,8 @@ RenameLanguage(const char *oldname, const char *newname)
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("language \"%s\" does not exist", oldname)));
|
||||
|
||||
lanId = HeapTupleGetOid(tup);
|
||||
|
||||
/* make sure the new name doesn't exist */
|
||||
if (SearchSysCacheExists1(LANGNAME, CStringGetDatum(newname)))
|
||||
ereport(ERROR,
|
||||
@@ -569,6 +572,8 @@ RenameLanguage(const char *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return lanId;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -38,7 +38,7 @@ static void AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerI
|
||||
/*
|
||||
* CREATE SCHEMA
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)
|
||||
{
|
||||
const char *schemaName = stmt->schemaname;
|
||||
@@ -97,7 +97,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)
|
||||
(errcode(ERRCODE_DUPLICATE_SCHEMA),
|
||||
errmsg("schema \"%s\" already exists, skipping",
|
||||
schemaName)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -163,6 +163,8 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)
|
||||
|
||||
/* Reset current user and security context */
|
||||
SetUserIdAndSecContext(saved_uid, save_sec_context);
|
||||
|
||||
return namespaceId;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -192,9 +194,10 @@ RemoveSchemaById(Oid schemaOid)
|
||||
/*
|
||||
* Rename schema
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameSchema(const char *oldname, const char *newname)
|
||||
{
|
||||
Oid nspOid;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
AclResult aclresult;
|
||||
@@ -207,6 +210,8 @@ RenameSchema(const char *oldname, const char *newname)
|
||||
(errcode(ERRCODE_UNDEFINED_SCHEMA),
|
||||
errmsg("schema \"%s\" does not exist", oldname)));
|
||||
|
||||
nspOid = HeapTupleGetOid(tup);
|
||||
|
||||
/* make sure the new name doesn't exist */
|
||||
if (OidIsValid(get_namespace_oid(newname, true)))
|
||||
ereport(ERROR,
|
||||
@@ -237,6 +242,8 @@ RenameSchema(const char *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return nspOid;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -262,9 +269,10 @@ AlterSchemaOwner_oid(Oid oid, Oid newOwnerId)
|
||||
/*
|
||||
* Change schema owner
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterSchemaOwner(const char *name, Oid newOwnerId)
|
||||
{
|
||||
Oid nspOid;
|
||||
HeapTuple tup;
|
||||
Relation rel;
|
||||
|
||||
@@ -276,11 +284,15 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
|
||||
(errcode(ERRCODE_UNDEFINED_SCHEMA),
|
||||
errmsg("schema \"%s\" does not exist", name)));
|
||||
|
||||
nspOid = HeapTupleGetOid(tup);
|
||||
|
||||
AlterSchemaOwner_internal(tup, rel, newOwnerId);
|
||||
|
||||
ReleaseSysCache(tup);
|
||||
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return nspOid;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -103,7 +103,7 @@ static void process_owned_by(Relation seqrel, List *owned_by);
|
||||
* DefineSequence
|
||||
* Creates a new sequence relation
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineSequence(CreateSeqStmt *seq)
|
||||
{
|
||||
FormData_pg_sequence new;
|
||||
@@ -228,6 +228,8 @@ DefineSequence(CreateSeqStmt *seq)
|
||||
process_owned_by(rel, owned_by);
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
|
||||
return seqoid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -400,7 +402,7 @@ fill_seq_with_data(Relation rel, HeapTuple tuple)
|
||||
*
|
||||
* Modify the definition of a sequence relation
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterSequence(AlterSeqStmt *stmt)
|
||||
{
|
||||
Oid relid;
|
||||
@@ -419,7 +421,7 @@ AlterSequence(AlterSeqStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->sequence->relname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
init_sequence(relid, &elm, &seqrel);
|
||||
@@ -483,6 +485,8 @@ AlterSequence(AlterSeqStmt *stmt)
|
||||
process_owned_by(seqrel, owned_by);
|
||||
|
||||
relation_close(seqrel, NoLock);
|
||||
|
||||
return relid;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -2098,7 +2098,7 @@ renameatt_internal(Oid myrelid,
|
||||
Relation targetrelation;
|
||||
Relation attrelation;
|
||||
HeapTuple atttup;
|
||||
Form_pg_attribute attform;
|
||||
Form_pg_attribute attform;
|
||||
int attnum;
|
||||
|
||||
/*
|
||||
@@ -2248,7 +2248,7 @@ RangeVarCallbackForRenameAttribute(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
/*
|
||||
* renameatt - changes the name of a attribute in a relation
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
renameatt(RenameStmt *stmt)
|
||||
{
|
||||
Oid relid;
|
||||
@@ -2264,7 +2264,7 @@ renameatt(RenameStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->relation->relname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
renameatt_internal(relid,
|
||||
@@ -2274,13 +2274,16 @@ renameatt(RenameStmt *stmt)
|
||||
false, /* recursing? */
|
||||
0, /* expected inhcount */
|
||||
stmt->behavior);
|
||||
|
||||
/* This is an ALTER TABLE command so it's about the relid */
|
||||
return relid;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* same logic as renameatt_internal
|
||||
*/
|
||||
static void
|
||||
static Oid
|
||||
rename_constraint_internal(Oid myrelid,
|
||||
Oid mytypid,
|
||||
const char *oldconname,
|
||||
@@ -2372,9 +2375,11 @@ rename_constraint_internal(Oid myrelid,
|
||||
|
||||
if (targetrelation)
|
||||
relation_close(targetrelation, NoLock); /* close rel but keep lock */
|
||||
|
||||
return constraintOid;
|
||||
}
|
||||
|
||||
void
|
||||
Oid
|
||||
RenameConstraint(RenameStmt *stmt)
|
||||
{
|
||||
Oid relid = InvalidOid;
|
||||
@@ -2403,18 +2408,20 @@ RenameConstraint(RenameStmt *stmt)
|
||||
NULL);
|
||||
}
|
||||
|
||||
rename_constraint_internal(relid, typid,
|
||||
stmt->subname,
|
||||
stmt->newname,
|
||||
stmt->relation ? interpretInhOption(stmt->relation->inhOpt) : false, /* recursive? */
|
||||
false, /* recursing? */
|
||||
0 /* expected inhcount */ );
|
||||
return
|
||||
rename_constraint_internal(relid, typid,
|
||||
stmt->subname,
|
||||
stmt->newname,
|
||||
stmt->relation ? interpretInhOption(stmt->relation->inhOpt) : false, /* recursive? */
|
||||
false, /* recursing? */
|
||||
0 /* expected inhcount */ );
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute ALTER TABLE/INDEX/SEQUENCE/VIEW/FOREIGN TABLE RENAME
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameRelation(RenameStmt *stmt)
|
||||
{
|
||||
Oid relid;
|
||||
@@ -2436,11 +2443,13 @@ RenameRelation(RenameStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->relation->relname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
/* Do the work */
|
||||
RenameRelationInternal(relid, stmt->newname);
|
||||
|
||||
return relid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -9746,7 +9755,7 @@ ATExecGenericOptions(Relation rel, List *options)
|
||||
/*
|
||||
* Execute ALTER TABLE SET SCHEMA
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterTableNamespace(AlterObjectSchemaStmt *stmt)
|
||||
{
|
||||
Relation rel;
|
||||
@@ -9766,7 +9775,7 @@ AlterTableNamespace(AlterObjectSchemaStmt *stmt)
|
||||
ereport(NOTICE,
|
||||
(errmsg("relation \"%s\" does not exist, skipping",
|
||||
stmt->relation->relname)));
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
|
||||
rel = relation_open(relid, NoLock);
|
||||
@@ -9801,6 +9810,8 @@ AlterTableNamespace(AlterObjectSchemaStmt *stmt)
|
||||
|
||||
/* close rel, but keep lock until commit */
|
||||
relation_close(rel, NoLock);
|
||||
|
||||
return relid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -818,9 +818,10 @@ directory_is_empty(const char *path)
|
||||
/*
|
||||
* Rename a tablespace
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameTableSpace(const char *oldname, const char *newname)
|
||||
{
|
||||
Oid tspId;
|
||||
Relation rel;
|
||||
ScanKeyData entry[1];
|
||||
HeapScanDesc scan;
|
||||
@@ -843,6 +844,7 @@ RenameTableSpace(const char *oldname, const char *newname)
|
||||
errmsg("tablespace \"%s\" does not exist",
|
||||
oldname)));
|
||||
|
||||
tspId = HeapTupleGetOid(tup);
|
||||
newtuple = heap_copytuple(tup);
|
||||
newform = (Form_pg_tablespace) GETSTRUCT(newtuple);
|
||||
|
||||
@@ -881,6 +883,8 @@ RenameTableSpace(const char *oldname, const char *newname)
|
||||
CatalogUpdateIndexes(rel, newtuple);
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
|
||||
return tspId;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1193,9 +1193,10 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
* modify tgname in trigger tuple
|
||||
* update row in catalog
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
renametrig(RenameStmt *stmt)
|
||||
{
|
||||
Oid tgoid;
|
||||
Relation targetrel;
|
||||
Relation tgrel;
|
||||
HeapTuple tuple;
|
||||
@@ -1261,6 +1262,7 @@ renametrig(RenameStmt *stmt)
|
||||
SnapshotNow, 2, key);
|
||||
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
|
||||
{
|
||||
tgoid = HeapTupleGetOid(tuple);
|
||||
/*
|
||||
* Update pg_trigger tuple with new tgname.
|
||||
*/
|
||||
@@ -1297,6 +1299,8 @@ renametrig(RenameStmt *stmt)
|
||||
* Close rel, but keep exclusive lock!
|
||||
*/
|
||||
relation_close(targetrel, NoLock);
|
||||
|
||||
return tgoid;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -167,7 +167,7 @@ makeParserDependencies(HeapTuple tuple)
|
||||
/*
|
||||
* CREATE TEXT SEARCH PARSER
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineTSParser(List *names, List *parameters)
|
||||
{
|
||||
char *prsname;
|
||||
@@ -278,6 +278,8 @@ DefineTSParser(List *names, List *parameters)
|
||||
heap_freetuple(tup);
|
||||
|
||||
heap_close(prsRel, RowExclusiveLock);
|
||||
|
||||
return prsOid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -306,7 +308,7 @@ RemoveTSParserById(Oid prsId)
|
||||
/*
|
||||
* ALTER TEXT SEARCH PARSER RENAME
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameTSParser(List *oldname, const char *newname)
|
||||
{
|
||||
HeapTuple tup;
|
||||
@@ -344,6 +346,8 @@ RenameTSParser(List *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return prsId;
|
||||
}
|
||||
|
||||
/* ---------------------- TS Dictionary commands -----------------------*/
|
||||
@@ -439,7 +443,7 @@ verify_dictoptions(Oid tmplId, List *dictoptions)
|
||||
/*
|
||||
* CREATE TEXT SEARCH DICTIONARY
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineTSDictionary(List *names, List *parameters)
|
||||
{
|
||||
ListCell *pl;
|
||||
@@ -526,12 +530,14 @@ DefineTSDictionary(List *names, List *parameters)
|
||||
heap_freetuple(tup);
|
||||
|
||||
heap_close(dictRel, RowExclusiveLock);
|
||||
|
||||
return dictOid;
|
||||
}
|
||||
|
||||
/*
|
||||
* ALTER TEXT SEARCH DICTIONARY RENAME
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameTSDictionary(List *oldname, const char *newname)
|
||||
{
|
||||
HeapTuple tup;
|
||||
@@ -577,6 +583,8 @@ RenameTSDictionary(List *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return dictId;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -803,7 +811,7 @@ makeTSTemplateDependencies(HeapTuple tuple)
|
||||
/*
|
||||
* CREATE TEXT SEARCH TEMPLATE
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineTSTemplate(List *names, List *parameters)
|
||||
{
|
||||
ListCell *pl;
|
||||
@@ -813,7 +821,7 @@ DefineTSTemplate(List *names, List *parameters)
|
||||
bool nulls[Natts_pg_ts_template];
|
||||
NameData dname;
|
||||
int i;
|
||||
Oid dictOid;
|
||||
Oid tmplOid;
|
||||
Oid namespaceoid;
|
||||
char *tmplname;
|
||||
|
||||
@@ -877,7 +885,7 @@ DefineTSTemplate(List *names, List *parameters)
|
||||
|
||||
tup = heap_form_tuple(tmplRel->rd_att, values, nulls);
|
||||
|
||||
dictOid = simple_heap_insert(tmplRel, tup);
|
||||
tmplOid = simple_heap_insert(tmplRel, tup);
|
||||
|
||||
CatalogUpdateIndexes(tmplRel, tup);
|
||||
|
||||
@@ -885,17 +893,19 @@ DefineTSTemplate(List *names, List *parameters)
|
||||
|
||||
/* Post creation hook for new text search template */
|
||||
InvokeObjectAccessHook(OAT_POST_CREATE,
|
||||
TSTemplateRelationId, dictOid, 0, NULL);
|
||||
TSTemplateRelationId, tmplOid, 0, NULL);
|
||||
|
||||
heap_freetuple(tup);
|
||||
|
||||
heap_close(tmplRel, RowExclusiveLock);
|
||||
|
||||
return tmplOid;
|
||||
}
|
||||
|
||||
/*
|
||||
* ALTER TEXT SEARCH TEMPLATE RENAME
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameTSTemplate(List *oldname, const char *newname)
|
||||
{
|
||||
HeapTuple tup;
|
||||
@@ -934,6 +944,8 @@ RenameTSTemplate(List *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return tmplId;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1076,7 +1088,7 @@ makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
|
||||
/*
|
||||
* CREATE TEXT SEARCH CONFIGURATION
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineTSConfiguration(List *names, List *parameters)
|
||||
{
|
||||
Relation cfgRel;
|
||||
@@ -1230,12 +1242,14 @@ DefineTSConfiguration(List *names, List *parameters)
|
||||
if (mapRel)
|
||||
heap_close(mapRel, RowExclusiveLock);
|
||||
heap_close(cfgRel, RowExclusiveLock);
|
||||
|
||||
return cfgOid;
|
||||
}
|
||||
|
||||
/*
|
||||
* ALTER TEXT SEARCH CONFIGURATION RENAME
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameTSConfiguration(List *oldname, const char *newname)
|
||||
{
|
||||
HeapTuple tup;
|
||||
@@ -1280,6 +1294,8 @@ RenameTSConfiguration(List *oldname, const char *newname)
|
||||
|
||||
heap_close(rel, NoLock);
|
||||
heap_freetuple(tup);
|
||||
|
||||
return cfgId;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -111,7 +111,7 @@ static char *domainAddConstraint(Oid domainOid, Oid domainNamespace,
|
||||
* DefineType
|
||||
* Registers a new base type.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineType(List *names, List *parameters)
|
||||
{
|
||||
char *typeName;
|
||||
@@ -225,7 +225,7 @@ DefineType(List *names, List *parameters)
|
||||
* creating the shell type was all we're supposed to do.
|
||||
*/
|
||||
if (parameters == NIL)
|
||||
return;
|
||||
return InvalidOid;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -593,39 +593,41 @@ DefineType(List *names, List *parameters)
|
||||
/* alignment must be 'i' or 'd' for arrays */
|
||||
alignment = (alignment == 'd') ? 'd' : 'i';
|
||||
|
||||
TypeCreate(array_oid, /* force assignment of this type OID */
|
||||
array_type, /* type name */
|
||||
typeNamespace, /* namespace */
|
||||
InvalidOid, /* relation oid (n/a here) */
|
||||
0, /* relation kind (ditto) */
|
||||
GetUserId(), /* owner's ID */
|
||||
-1, /* internal size (always varlena) */
|
||||
TYPTYPE_BASE, /* type-type (base type) */
|
||||
TYPCATEGORY_ARRAY, /* type-category (array) */
|
||||
false, /* array types are never preferred */
|
||||
delimiter, /* array element delimiter */
|
||||
F_ARRAY_IN, /* input procedure */
|
||||
F_ARRAY_OUT, /* output procedure */
|
||||
F_ARRAY_RECV, /* receive procedure */
|
||||
F_ARRAY_SEND, /* send procedure */
|
||||
typmodinOid, /* typmodin procedure */
|
||||
typmodoutOid, /* typmodout procedure */
|
||||
F_ARRAY_TYPANALYZE, /* analyze procedure */
|
||||
typoid, /* element type ID */
|
||||
true, /* yes this is an array type */
|
||||
InvalidOid, /* no further array type */
|
||||
InvalidOid, /* base type ID */
|
||||
NULL, /* never a default type value */
|
||||
NULL, /* binary default isn't sent either */
|
||||
false, /* never passed by value */
|
||||
alignment, /* see above */
|
||||
'x', /* ARRAY is always toastable */
|
||||
-1, /* typMod (Domains only) */
|
||||
0, /* Array dimensions of typbasetype */
|
||||
false, /* Type NOT NULL */
|
||||
collation); /* type's collation */
|
||||
typoid = TypeCreate(array_oid, /* force assignment of this type OID */
|
||||
array_type, /* type name */
|
||||
typeNamespace, /* namespace */
|
||||
InvalidOid, /* relation oid (n/a here) */
|
||||
0, /* relation kind (ditto) */
|
||||
GetUserId(), /* owner's ID */
|
||||
-1, /* internal size (always varlena) */
|
||||
TYPTYPE_BASE, /* type-type (base type) */
|
||||
TYPCATEGORY_ARRAY, /* type-category (array) */
|
||||
false, /* array types are never preferred */
|
||||
delimiter, /* array element delimiter */
|
||||
F_ARRAY_IN, /* input procedure */
|
||||
F_ARRAY_OUT, /* output procedure */
|
||||
F_ARRAY_RECV, /* receive procedure */
|
||||
F_ARRAY_SEND, /* send procedure */
|
||||
typmodinOid, /* typmodin procedure */
|
||||
typmodoutOid, /* typmodout procedure */
|
||||
F_ARRAY_TYPANALYZE, /* analyze procedure */
|
||||
typoid, /* element type ID */
|
||||
true, /* yes this is an array type */
|
||||
InvalidOid, /* no further array type */
|
||||
InvalidOid, /* base type ID */
|
||||
NULL, /* never a default type value */
|
||||
NULL, /* binary default isn't sent either */
|
||||
false, /* never passed by value */
|
||||
alignment, /* see above */
|
||||
'x', /* ARRAY is always toastable */
|
||||
-1, /* typMod (Domains only) */
|
||||
0, /* Array dimensions of typbasetype */
|
||||
false, /* Type NOT NULL */
|
||||
collation); /* type's collation */
|
||||
|
||||
pfree(array_type);
|
||||
|
||||
return typoid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -671,7 +673,7 @@ RemoveTypeById(Oid typeOid)
|
||||
* DefineDomain
|
||||
* Registers a new domain.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineDomain(CreateDomainStmt *stmt)
|
||||
{
|
||||
char *domainName;
|
||||
@@ -1042,6 +1044,8 @@ DefineDomain(CreateDomainStmt *stmt)
|
||||
* Now we can clean up.
|
||||
*/
|
||||
ReleaseSysCache(typeTup);
|
||||
|
||||
return domainoid;
|
||||
}
|
||||
|
||||
|
||||
@@ -3092,7 +3096,7 @@ GetDomainConstraints(Oid typeOid)
|
||||
/*
|
||||
* Execute ALTER TYPE RENAME
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameType(RenameStmt *stmt)
|
||||
{
|
||||
List *names = stmt->object;
|
||||
@@ -3161,12 +3165,14 @@ RenameType(RenameStmt *stmt)
|
||||
|
||||
/* Clean up */
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return typeOid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Change the owner of a type.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
|
||||
{
|
||||
TypeName *typename;
|
||||
@@ -3283,6 +3289,8 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
|
||||
|
||||
/* Clean up */
|
||||
heap_close(rel, RowExclusiveLock);
|
||||
|
||||
return typeOid;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3335,7 +3343,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId,
|
||||
/*
|
||||
* Execute ALTER TYPE SET SCHEMA
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype)
|
||||
{
|
||||
TypeName *typename;
|
||||
@@ -3360,6 +3368,8 @@ AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype)
|
||||
objsMoved = new_object_addresses();
|
||||
AlterTypeNamespace_oid(typeOid, nspOid, objsMoved);
|
||||
free_object_addresses(objsMoved);
|
||||
|
||||
return typeOid;
|
||||
}
|
||||
|
||||
Oid
|
||||
|
@@ -1036,7 +1036,7 @@ DropRole(DropRoleStmt *stmt)
|
||||
/*
|
||||
* Rename role
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
RenameRole(const char *oldname, const char *newname)
|
||||
{
|
||||
HeapTuple oldtuple,
|
||||
@@ -1142,6 +1142,8 @@ RenameRole(const char *oldname, const char *newname)
|
||||
* Close pg_authid, but keep lock till commit.
|
||||
*/
|
||||
heap_close(rel, NoLock);
|
||||
|
||||
return roleid;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -420,7 +420,7 @@ UpdateRangeTableOfViewParse(Oid viewOid, Query *viewParse)
|
||||
* DefineView
|
||||
* Execute a CREATE VIEW command.
|
||||
*/
|
||||
void
|
||||
Oid
|
||||
DefineView(ViewStmt *stmt, const char *queryString)
|
||||
{
|
||||
Query *viewParse;
|
||||
@@ -540,4 +540,6 @@ DefineView(ViewStmt *stmt, const char *queryString)
|
||||
* Now create the rules associated with the view.
|
||||
*/
|
||||
DefineViewRules(viewOid, viewParse, stmt->replace);
|
||||
|
||||
return viewOid;
|
||||
}
|
||||
|
Reference in New Issue
Block a user