/*
* AggregateCreate
*/
-void
+Oid
AggregateCreate(const char *aggName,
Oid aggNamespace,
Oid *aggArgTypes,
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
+
+ return procOid;
}
/*
* Forward declaration is used only for this purpose, it is
* not available to the user as it is for type definition.
*/
-void
+Oid
OperatorCreate(const char *operatorName,
Oid operatorNamespace,
Oid leftTypeId,
if (OidIsValid(commutatorId) || OidIsValid(negatorId))
OperatorUpd(operatorObjectId, commutatorId, negatorId);
+
+ return operatorObjectId;
}
/*
* 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;
/*
* 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 */
}
* RenameAggregate
* Rename an aggregate.
*/
-void
+Oid
RenameAggregate(List *name, List *args, const char *newname)
{
Oid procOid;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return procOid;
}
* 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 */
}
}
* 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:
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 */
}
}
* 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);
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:
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 */
}
}
/*
* CREATE COLLATION
*/
-void
+Oid
DefineCollation(List *names, List *parameters)
{
char *collName;
/* 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;
heap_freetuple(tup);
heap_close(rel, RowExclusiveLock);
+
+ return collationOid;
}
/*
* Execute ALTER COLLATION SET SCHEMA
*/
-void
+Oid
AlterCollationNamespace(List *name, const char *newschema)
{
Oid collOid,
nspOid = LookupCreationNamespace(newschema);
AlterCollationNamespace_oid(collOid, nspOid);
+
+ return collOid;
}
/*
/*
* CREATE CONVERSION
*/
-void
+Oid
CreateConversionCommand(CreateConversionStmt *stmt)
{
Oid namespaceId;
* 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;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return conversionOid;
}
/*
* Rename database
*/
-void
+Oid
RenameDatabase(const char *oldname, const char *newname)
{
Oid db_id;
* Close pg_database, but keep lock till commit.
*/
heap_close(rel, NoLock);
+
+ return db_id;
}
/*
* ALTER DATABASE name OWNER TO newowner
*/
-void
+Oid
AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
{
+ Oid db_id;
HeapTuple tuple;
Relation rel;
ScanKeyData scankey;
(errcode(ERRCODE_UNDEFINED_DATABASE),
errmsg("database \"%s\" does not exist", dbname)));
+ db_id = HeapTupleGetOid(tuple);
datForm = (Form_pg_database) GETSTRUCT(tuple);
/*
/* Close pg_database, but keep lock till commit */
heap_close(rel, NoLock);
+
+ return db_id;
}
/*
* Rename event trigger
*/
-void
+Oid
RenameEventTrigger(const char *trigname, const char *newname)
{
+ Oid evtId;
HeapTuple tup;
Relation rel;
Form_pg_event_trigger evtForm;
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 */
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;
(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;
}
/*
/*
* CREATE EXTENSION
*/
-void
+Oid
CreateExtension(CreateExtensionStmt *stmt)
{
DefElem *d_schema = NULL;
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("extension \"%s\" already exists, skipping",
stmt->extname)));
- return;
+ return InvalidOid;
}
else
ereport(ERROR,
*/
ApplyExtensionUpdates(extensionOid, pcontrol,
versionName, updateVersions);
+
+ return extensionOid;
}
/*
/*
* Execute ALTER EXTENSION SET SCHEMA
*/
-void
+Oid
AlterExtensionNamespace(List *names, const char *newschema)
{
char *extensionName;
if (extForm->extnamespace == nspOid)
{
heap_close(extRel, RowExclusiveLock);
- return;
+ return InvalidOid;
}
/* Check extension is supposed to be relocatable */
/* update dependencies to point to the new schema */
changeDependencyFor(ExtensionRelationId, extensionOid,
NamespaceRelationId, oldNspOid, nspOid);
+
+ return extensionOid;
}
/*
/*
* Rename foreign-data wrapper
*/
-void
+Oid
RenameForeignDataWrapper(const char *oldname, const char *newname)
{
+ Oid fdwId;
HeapTuple tup;
Relation rel;
(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,
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;
(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,
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return srvId;
}
*
* Note restrictions in the "_internal" function, above.
*/
-void
+Oid
AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
{
+ Oid fdwId;
HeapTuple tup;
Relation rel;
(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;
}
/*
/*
* Change foreign server owner -- by name
*/
-void
+Oid
AlterForeignServerOwner(const char *name, Oid newOwnerId)
{
+ Oid servOid;
HeapTuple tup;
Relation rel;
(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;
}
/*
* CreateFunction
* Execute a CREATE FUNCTION utility statement.
*/
-void
+Oid
CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
{
char *probin_str;
* 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);
}
/*
* Rename function
*/
-void
+Oid
RenameFunction(List *name, List *argtypes, const char *newname)
{
Oid procOid;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return procOid;
}
/*
*
* These commands are identical except for the lookup procedure, so share code.
*/
-void
+Oid
AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
const char *newschema)
{
nspOid = LookupCreationNamespace(newschema);
AlterFunctionNamespace_oid(procOid, nspOid);
+
+ return procOid;
}
Oid
/*
* Rename opclass
*/
-void
+Oid
RenameOpClass(List *name, const char *access_method, const char *newname)
{
Oid opcOid;
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;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return opfOid;
}
/*
*
* 'parameters' is a list of DefElem
*/
-void
+Oid
DefineOperator(List *names, List *parameters)
{
char *oprName;
/*
* 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.
*/
/*
* Rename language
*/
-void
+Oid
RenameLanguage(const char *oldname, const char *newname)
{
+ Oid lanId;
HeapTuple tup;
Relation rel;
(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,
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return lanId;
}
/*
/*
* CREATE SCHEMA
*/
-void
+Oid
CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)
{
const char *schemaName = stmt->schemaname;
(errcode(ERRCODE_DUPLICATE_SCHEMA),
errmsg("schema \"%s\" already exists, skipping",
schemaName)));
- return;
+ return InvalidOid;
}
/*
/* Reset current user and security context */
SetUserIdAndSecContext(saved_uid, save_sec_context);
+
+ return namespaceId;
}
/*
/*
* Rename schema
*/
-void
+Oid
RenameSchema(const char *oldname, const char *newname)
{
+ Oid nspOid;
HeapTuple tup;
Relation rel;
AclResult aclresult;
(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,
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return nspOid;
}
void
/*
* Change schema owner
*/
-void
+Oid
AlterSchemaOwner(const char *name, Oid newOwnerId)
{
+ Oid nspOid;
HeapTuple tup;
Relation rel;
(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
* DefineSequence
* Creates a new sequence relation
*/
-void
+Oid
DefineSequence(CreateSeqStmt *seq)
{
FormData_pg_sequence new;
process_owned_by(rel, owned_by);
heap_close(rel, NoLock);
+
+ return seqoid;
}
/*
*
* Modify the definition of a sequence relation
*/
-void
+Oid
AlterSequence(AlterSeqStmt *stmt)
{
Oid relid;
ereport(NOTICE,
(errmsg("relation \"%s\" does not exist, skipping",
stmt->sequence->relname)));
- return;
+ return InvalidOid;
}
init_sequence(relid, &elm, &seqrel);
process_owned_by(seqrel, owned_by);
relation_close(seqrel, NoLock);
+
+ return relid;
}
Relation targetrelation;
Relation attrelation;
HeapTuple atttup;
- Form_pg_attribute attform;
+ Form_pg_attribute attform;
int attnum;
/*
/*
* renameatt - changes the name of a attribute in a relation
*/
-void
+Oid
renameatt(RenameStmt *stmt)
{
Oid relid;
ereport(NOTICE,
(errmsg("relation \"%s\" does not exist, skipping",
stmt->relation->relname)));
- return;
+ return InvalidOid;
}
renameatt_internal(relid,
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,
if (targetrelation)
relation_close(targetrelation, NoLock); /* close rel but keep lock */
+
+ return constraintOid;
}
-void
+Oid
RenameConstraint(RenameStmt *stmt)
{
Oid relid = InvalidOid;
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;
ereport(NOTICE,
(errmsg("relation \"%s\" does not exist, skipping",
stmt->relation->relname)));
- return;
+ return InvalidOid;
}
/* Do the work */
RenameRelationInternal(relid, stmt->newname);
+
+ return relid;
}
/*
/*
* Execute ALTER TABLE SET SCHEMA
*/
-void
+Oid
AlterTableNamespace(AlterObjectSchemaStmt *stmt)
{
Relation rel;
ereport(NOTICE,
(errmsg("relation \"%s\" does not exist, skipping",
stmt->relation->relname)));
- return;
+ return InvalidOid;
}
rel = relation_open(relid, NoLock);
/* close rel, but keep lock until commit */
relation_close(rel, NoLock);
+
+ return relid;
}
/*
/*
* Rename a tablespace
*/
-void
+Oid
RenameTableSpace(const char *oldname, const char *newname)
{
+ Oid tspId;
Relation rel;
ScanKeyData entry[1];
HeapScanDesc scan;
errmsg("tablespace \"%s\" does not exist",
oldname)));
+ tspId = HeapTupleGetOid(tup);
newtuple = heap_copytuple(tup);
newform = (Form_pg_tablespace) GETSTRUCT(newtuple);
CatalogUpdateIndexes(rel, newtuple);
heap_close(rel, NoLock);
+
+ return tspId;
}
/*
* modify tgname in trigger tuple
* update row in catalog
*/
-void
+Oid
renametrig(RenameStmt *stmt)
{
+ Oid tgoid;
Relation targetrel;
Relation tgrel;
HeapTuple tuple;
SnapshotNow, 2, key);
if (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
+ tgoid = HeapTupleGetOid(tuple);
/*
* Update pg_trigger tuple with new tgname.
*/
* Close rel, but keep exclusive lock!
*/
relation_close(targetrel, NoLock);
+
+ return tgoid;
}
/*
* CREATE TEXT SEARCH PARSER
*/
-void
+Oid
DefineTSParser(List *names, List *parameters)
{
char *prsname;
heap_freetuple(tup);
heap_close(prsRel, RowExclusiveLock);
+
+ return prsOid;
}
/*
/*
* ALTER TEXT SEARCH PARSER RENAME
*/
-void
+Oid
RenameTSParser(List *oldname, const char *newname)
{
HeapTuple tup;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return prsId;
}
/* ---------------------- TS Dictionary commands -----------------------*/
/*
* CREATE TEXT SEARCH DICTIONARY
*/
-void
+Oid
DefineTSDictionary(List *names, List *parameters)
{
ListCell *pl;
heap_freetuple(tup);
heap_close(dictRel, RowExclusiveLock);
+
+ return dictOid;
}
/*
* ALTER TEXT SEARCH DICTIONARY RENAME
*/
-void
+Oid
RenameTSDictionary(List *oldname, const char *newname)
{
HeapTuple tup;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return dictId;
}
/*
/*
* CREATE TEXT SEARCH TEMPLATE
*/
-void
+Oid
DefineTSTemplate(List *names, List *parameters)
{
ListCell *pl;
bool nulls[Natts_pg_ts_template];
NameData dname;
int i;
- Oid dictOid;
+ Oid tmplOid;
Oid namespaceoid;
char *tmplname;
tup = heap_form_tuple(tmplRel->rd_att, values, nulls);
- dictOid = simple_heap_insert(tmplRel, tup);
+ tmplOid = simple_heap_insert(tmplRel, tup);
CatalogUpdateIndexes(tmplRel, tup);
/* 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;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return tmplId;
}
/*
/*
* CREATE TEXT SEARCH CONFIGURATION
*/
-void
+Oid
DefineTSConfiguration(List *names, List *parameters)
{
Relation cfgRel;
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;
heap_close(rel, NoLock);
heap_freetuple(tup);
+
+ return cfgId;
}
/*
* DefineType
* Registers a new base type.
*/
-void
+Oid
DefineType(List *names, List *parameters)
{
char *typeName;
* creating the shell type was all we're supposed to do.
*/
if (parameters == NIL)
- return;
+ return InvalidOid;
}
else
{
/* 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;
}
/*
* DefineDomain
* Registers a new domain.
*/
-void
+Oid
DefineDomain(CreateDomainStmt *stmt)
{
char *domainName;
* Now we can clean up.
*/
ReleaseSysCache(typeTup);
+
+ return domainoid;
}
/*
* Execute ALTER TYPE RENAME
*/
-void
+Oid
RenameType(RenameStmt *stmt)
{
List *names = stmt->object;
/* 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;
/* Clean up */
heap_close(rel, RowExclusiveLock);
+
+ return typeOid;
}
/*
/*
* Execute ALTER TYPE SET SCHEMA
*/
-void
+Oid
AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype)
{
TypeName *typename;
objsMoved = new_object_addresses();
AlterTypeNamespace_oid(typeOid, nspOid, objsMoved);
free_object_addresses(objsMoved);
+
+ return typeOid;
}
Oid
/*
* Rename role
*/
-void
+Oid
RenameRole(const char *oldname, const char *newname)
{
HeapTuple oldtuple,
* Close pg_authid, but keep lock till commit.
*/
heap_close(rel, NoLock);
+
+ return roleid;
}
/*
* DefineView
* Execute a CREATE VIEW command.
*/
-void
+Oid
DefineView(ViewStmt *stmt, const char *queryString)
{
Query *viewParse;
* Now create the rules associated with the view.
*/
DefineViewRules(viewOid, viewParse, stmt->replace);
+
+ return viewOid;
}
/*
* function prototypes
*/
-extern void OperatorCreate(const char *operatorName,
+extern Oid OperatorCreate(const char *operatorName,
Oid operatorNamespace,
Oid leftTypeId,
Oid rightTypeId,
#include "nodes/parsenodes.h"
#include "utils/relcache.h"
-extern void ExecRenameStmt(RenameStmt *stmt);
+extern Oid ExecRenameStmt(RenameStmt *stmt);
-extern void ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt);
+extern Oid ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt);
extern Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid,
ObjectAddresses *objsMoved);
extern Oid AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid);
-extern void ExecAlterOwnerStmt(AlterOwnerStmt *stmt);
+extern Oid ExecAlterOwnerStmt(AlterOwnerStmt *stmt);
extern void AlterObjectOwner_internal(Relation catalog, Oid objectId,
Oid new_ownerId);
#include "nodes/parsenodes.h"
-extern void DefineCollation(List *names, List *parameters);
-extern void RenameCollation(List *name, const char *newname);
-extern void AlterCollationNamespace(List *name, const char *newschema);
+extern Oid DefineCollation(List *names, List *parameters);
+extern Oid RenameCollation(List *name, const char *newname);
+extern Oid AlterCollationNamespace(List *name, const char *newschema);
extern Oid AlterCollationNamespace_oid(Oid collOid, Oid newNspOid);
#endif /* COLLATIONCMDS_H */
#include "nodes/parsenodes.h"
-extern void CreateConversionCommand(CreateConversionStmt *parsetree);
-extern void RenameConversion(List *name, const char *newname);
+extern Oid CreateConversionCommand(CreateConversionStmt *parsetree);
+extern Oid RenameConversion(List *name, const char *newname);
#endif /* CONVERSIONCMDS_H */
extern void createdb(const CreatedbStmt *stmt);
extern void dropdb(const char *dbname, bool missing_ok);
-extern void RenameDatabase(const char *oldname, const char *newname);
+extern Oid RenameDatabase(const char *oldname, const char *newname);
extern void AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel);
extern void AlterDatabaseSet(AlterDatabaseSetStmt *stmt);
-extern void AlterDatabaseOwner(const char *dbname, Oid newOwnerId);
+extern Oid AlterDatabaseOwner(const char *dbname, Oid newOwnerId);
extern Oid get_database_oid(const char *dbname, bool missingok);
extern char *get_database_name(Oid dbid);
extern Oid GetDefaultOpClass(Oid type_id, Oid am_id);
/* commands/functioncmds.c */
-extern void CreateFunction(CreateFunctionStmt *stmt, const char *queryString);
+extern Oid CreateFunction(CreateFunctionStmt *stmt, const char *queryString);
extern void RemoveFunctionById(Oid funcOid);
extern void SetFunctionReturnType(Oid funcOid, Oid newRetType);
extern void SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType);
-extern void RenameFunction(List *name, List *argtypes, const char *newname);
+extern Oid RenameFunction(List *name, List *argtypes, const char *newname);
extern void AlterFunction(AlterFunctionStmt *stmt);
extern void CreateCast(CreateCastStmt *stmt);
extern void DropCastById(Oid castOid);
-extern void AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
- const char *newschema);
+extern Oid AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
+ const char *newschema);
extern Oid AlterFunctionNamespace_oid(Oid procOid, Oid nspOid);
extern void ExecuteDoStmt(DoStmt *stmt);
extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);
/* commands/operatorcmds.c */
-extern void DefineOperator(List *names, List *parameters);
+extern Oid DefineOperator(List *names, List *parameters);
extern void RemoveOperatorById(Oid operOid);
/* commands/aggregatecmds.c */
-extern void DefineAggregate(List *name, List *args, bool oldstyle,
+extern Oid DefineAggregate(List *name, List *args, bool oldstyle,
List *parameters);
-extern void RenameAggregate(List *name, List *args, const char *newname);
+extern Oid RenameAggregate(List *name, List *args, const char *newname);
/* commands/opclasscmds.c */
extern void DefineOpClass(CreateOpClassStmt *stmt);
extern void RemoveOpFamilyById(Oid opfamilyOid);
extern void RemoveAmOpEntryById(Oid entryOid);
extern void RemoveAmProcEntryById(Oid entryOid);
-extern void RenameOpClass(List *name, const char *access_method, const char *newname);
-extern void RenameOpFamily(List *name, const char *access_method, const char *newname);
+extern Oid RenameOpClass(List *name, const char *access_method, const char *newname);
+extern Oid RenameOpFamily(List *name, const char *access_method, const char *newname);
extern Oid get_am_oid(const char *amname, bool missing_ok);
extern Oid get_opclass_oid(Oid amID, List *opclassname, bool missing_ok);
extern Oid get_opfamily_oid(Oid amID, List *opfamilyname, bool missing_ok);
/* commands/tsearchcmds.c */
-extern void DefineTSParser(List *names, List *parameters);
-extern void RenameTSParser(List *oldname, const char *newname);
+extern Oid DefineTSParser(List *names, List *parameters);
+extern Oid RenameTSParser(List *oldname, const char *newname);
extern void RemoveTSParserById(Oid prsId);
-extern void DefineTSDictionary(List *names, List *parameters);
-extern void RenameTSDictionary(List *oldname, const char *newname);
+extern Oid DefineTSDictionary(List *names, List *parameters);
+extern Oid RenameTSDictionary(List *oldname, const char *newname);
extern void RemoveTSDictionaryById(Oid dictId);
extern void AlterTSDictionary(AlterTSDictionaryStmt *stmt);
-extern void DefineTSTemplate(List *names, List *parameters);
-extern void RenameTSTemplate(List *oldname, const char *newname);
+extern Oid DefineTSTemplate(List *names, List *parameters);
+extern Oid RenameTSTemplate(List *oldname, const char *newname);
extern void RemoveTSTemplateById(Oid tmplId);
-extern void DefineTSConfiguration(List *names, List *parameters);
-extern void RenameTSConfiguration(List *oldname, const char *newname);
+extern Oid DefineTSConfiguration(List *names, List *parameters);
+extern Oid RenameTSConfiguration(List *oldname, const char *newname);
extern void RemoveTSConfigurationById(Oid cfgId);
extern void AlterTSConfiguration(AlterTSConfigurationStmt *stmt);
extern List *deserialize_deflist(Datum txt);
/* commands/foreigncmds.c */
-extern void RenameForeignServer(const char *oldname, const char *newname);
-extern void RenameForeignDataWrapper(const char *oldname, const char *newname);
-extern void AlterForeignServerOwner(const char *name, Oid newOwnerId);
+extern Oid RenameForeignServer(const char *oldname, const char *newname);
+extern Oid RenameForeignDataWrapper(const char *oldname, const char *newname);
+extern Oid AlterForeignServerOwner(const char *name, Oid newOwnerId);
extern void AlterForeignServerOwner_oid(Oid, Oid newOwnerId);
-extern void AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId);
+extern Oid AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId);
extern void AlterForeignDataWrapperOwner_oid(Oid fwdId, Oid newOwnerId);
extern void CreateForeignDataWrapper(CreateFdwStmt *stmt);
extern void AlterForeignDataWrapper(AlterFdwStmt *stmt);
extern Oid CurrentExtensionObject;
-extern void CreateExtension(CreateExtensionStmt *stmt);
+extern Oid CreateExtension(CreateExtensionStmt *stmt);
extern void RemoveExtensionById(Oid extId);
extern Oid get_extension_oid(const char *extname, bool missing_ok);
extern char *get_extension_name(Oid ext_oid);
-extern void AlterExtensionNamespace(List *names, const char *newschema);
+extern Oid AlterExtensionNamespace(List *names, const char *newschema);
extern void AlterExtensionOwner_oid(Oid extensionOid, Oid newOwnerId);
extern void CreateProceduralLanguage(CreatePLangStmt *stmt);
extern void DropProceduralLanguageById(Oid langOid);
-extern void RenameLanguage(const char *oldname, const char *newname);
+extern Oid RenameLanguage(const char *oldname, const char *newname);
extern bool PLTemplateExists(const char *languageName);
extern Oid get_language_oid(const char *langname, bool missing_ok);
#include "nodes/parsenodes.h"
-extern void CreateSchemaCommand(CreateSchemaStmt *parsetree,
+extern Oid CreateSchemaCommand(CreateSchemaStmt *parsetree,
const char *queryString);
extern void RemoveSchemaById(Oid schemaOid);
-extern void RenameSchema(const char *oldname, const char *newname);
-extern void AlterSchemaOwner(const char *name, Oid newOwnerId);
+extern Oid RenameSchema(const char *oldname, const char *newname);
+extern Oid AlterSchemaOwner(const char *name, Oid newOwnerId);
extern void AlterSchemaOwner_oid(Oid schemaOid, Oid newOwnerId);
#endif /* SCHEMACMDS_H */
extern Datum pg_sequence_parameters(PG_FUNCTION_ARGS);
-extern void DefineSequence(CreateSeqStmt *stmt);
-extern void AlterSequence(AlterSeqStmt *stmt);
+extern Oid DefineSequence(CreateSeqStmt *stmt);
+extern Oid AlterSequence(AlterSeqStmt *stmt);
extern void ResetSequence(Oid seq_relid);
extern void seq_redo(XLogRecPtr lsn, XLogRecord *rptr);
extern void SetRelationHasSubclass(Oid relationId, bool relhassubclass);
-extern void renameatt(RenameStmt *stmt);
+extern Oid renameatt(RenameStmt *stmt);
-extern void RenameConstraint(RenameStmt *stmt);
+extern Oid RenameConstraint(RenameStmt *stmt);
-extern void RenameRelation(RenameStmt *stmt);
+extern Oid RenameRelation(RenameStmt *stmt);
extern void RenameRelationInternal(Oid myrelid,
const char *newrelname);
extern void CreateTableSpace(CreateTableSpaceStmt *stmt);
extern void DropTableSpace(DropTableSpaceStmt *stmt);
-extern void RenameTableSpace(const char *oldname, const char *newname);
+extern Oid RenameTableSpace(const char *oldname, const char *newname);
extern void AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt);
extern void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo);
extern void RemoveTriggerById(Oid trigOid);
extern Oid get_trigger_oid(Oid relid, const char *name, bool missing_ok);
-extern void renametrig(RenameStmt *stmt);
+extern Oid renametrig(RenameStmt *stmt);
extern void EnableDisableTrigger(Relation rel, const char *tgname,
char fires_when, bool skip_system);
#define DEFAULT_TYPDELIM ','
-extern void DefineType(List *names, List *parameters);
+extern Oid DefineType(List *names, List *parameters);
extern void RemoveTypeById(Oid typeOid);
-extern void DefineDomain(CreateDomainStmt *stmt);
+extern Oid DefineDomain(CreateDomainStmt *stmt);
extern void DefineEnum(CreateEnumStmt *stmt);
extern void DefineRange(CreateRangeStmt *stmt);
extern void AlterEnum(AlterEnumStmt *stmt, bool isTopLevel);
extern List *GetDomainConstraints(Oid typeOid);
-extern void RenameType(RenameStmt *stmt);
-extern void AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype);
+extern Oid RenameType(RenameStmt *stmt);
+extern Oid AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype);
extern void AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId,
bool hasDependEntry);
-extern void AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype);
+extern Oid AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype);
extern Oid AlterTypeNamespace_oid(Oid typeOid, Oid nspOid, ObjectAddresses *objsMoved);
extern Oid AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
bool isImplicitArray,
extern void AlterRoleSet(AlterRoleSetStmt *stmt);
extern void DropRole(DropRoleStmt *stmt);
extern void GrantRole(GrantRoleStmt *stmt);
-extern void RenameRole(const char *oldname, const char *newname);
+extern Oid RenameRole(const char *oldname, const char *newname);
extern void DropOwnedObjects(DropOwnedStmt *stmt);
extern void ReassignOwnedObjects(ReassignOwnedStmt *stmt);
#include "nodes/parsenodes.h"
-extern void DefineView(ViewStmt *stmt, const char *queryString);
+extern Oid DefineView(ViewStmt *stmt, const char *queryString);
#endif /* VIEW_H */