Commits

Anonymous committed 82b1b21

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

  • Participants
  • Parent commits 5ab3af4
  • Branches jsonbuild, master

Comments (0)

Files changed (29)

File src/backend/commands/comment.c

  * This routine is used to add the associated comment into
  * pg_description for the object specified by the given SQL command.
  */
-void
+Oid
 CommentObject(CommentStmt *stmt)
 {
 	ObjectAddress address;
 			ereport(WARNING,
 					(errcode(ERRCODE_UNDEFINED_DATABASE),
 					 errmsg("database \"%s\" does not exist", database)));
-			return;
+			return InvalidOid;
 		}
 	}
 
 	 */
 	if (relation != NULL)
 		relation_close(relation, NoLock);
+
+	return address.objectId;
 }
 
 /*

File src/backend/commands/copy.c

  * Do not allow the copy if user doesn't have proper permission to access
  * the table or the specifically requested columns.
  */
-uint64
-DoCopy(const CopyStmt *stmt, const char *queryString)
+Oid
+DoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
 {
 	CopyState	cstate;
 	bool		is_from = stmt->is_from;
 	bool		pipe = (stmt->filename == NULL);
 	Relation	rel;
-	uint64		processed;
+	Oid         relid;
 
 	/* Disallow file COPY except to superusers. */
 	if (!pipe && !superuser())
 		rel = heap_openrv(stmt->relation,
 						  (is_from ? RowExclusiveLock : AccessShareLock));
 
+		relid = RelationGetRelid(rel);
+
 		rte = makeNode(RangeTblEntry);
 		rte->rtekind = RTE_RELATION;
 		rte->relid = RelationGetRelid(rel);
 
 		cstate = BeginCopyFrom(rel, stmt->filename,
 							   stmt->attlist, stmt->options);
-		processed = CopyFrom(cstate);	/* copy from file to database */
+		*processed = CopyFrom(cstate);	/* copy from file to database */
 		EndCopyFrom(cstate);
 	}
 	else
 	{
 		cstate = BeginCopyTo(rel, stmt->query, queryString, stmt->filename,
 							 stmt->attlist, stmt->options);
-		processed = DoCopyTo(cstate);	/* copy from database to file */
+		*processed = DoCopyTo(cstate);	/* copy from database to file */
 		EndCopyTo(cstate);
 	}
 
 	if (rel != NULL)
 		heap_close(rel, (is_from ? NoLock : AccessShareLock));
 
-	return processed;
+	return relid;
 }
 
 /*

File src/backend/commands/dbcommands.c

 /*
  * CREATE DATABASE
  */
-void
+Oid
 createdb(const CreatedbStmt *stmt)
 {
 	HeapScanDesc scan;
 	}
 	PG_END_ENSURE_ERROR_CLEANUP(createdb_failure_callback,
 								PointerGetDatum(&fparms));
+
+	return dboid;
 }
 
 /*
 /*
  * ALTER DATABASE name ...
  */
-void
+Oid
 AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
 {
 	Relation	rel;
+	Oid         dboid;
 	HeapTuple	tuple,
 				newtuple;
 	ScanKeyData scankey;
 		/* 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)
 				(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);
 
 	/* 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);
 	AlterSetting(datid, InvalidOid, stmt->setstmt);
 
 	UnlockSharedObject(DatabaseRelationId, datid, 0, AccessShareLock);
+
+	return datid;
 }
 
 

File src/backend/commands/event_trigger.c

 static event_trigger_command_tag_check_result check_ddl_tag(const char *tag);
 static void error_duplicate_filter_variable(const char *defname);
 static Datum filter_list_to_array(List *filterlist);
-static void insert_event_trigger_tuple(char *trigname, char *eventname,
-						Oid evtOwner, Oid funcoid, List *tags);
+static Oid insert_event_trigger_tuple(char *trigname, char *eventname,
+									  Oid evtOwner, Oid funcoid, List *tags);
 static void validate_ddl_tags(const char *filtervar, List *taglist);
 static void EventTriggerInvoke(List *fn_oid_list, EventTriggerData *trigdata);
 
 /*
  * Create an event trigger.
  */
-void
+Oid
 CreateEventTrigger(CreateEventTrigStmt *stmt)
 {
 	HeapTuple	tuple;
 						NameListToString(stmt->funcname))));
 
 	/* Insert catalog entries. */
-	insert_event_trigger_tuple(stmt->trigname, stmt->eventname,
-							   evtowner, funcoid, tags);
+	return insert_event_trigger_tuple(stmt->trigname, stmt->eventname,
+									  evtowner, funcoid, tags);
 }
 
 /*
 /*
  * Insert the new pg_event_trigger row and record dependencies.
  */
-static void
+static Oid
 insert_event_trigger_tuple(char *trigname, char *eventname, Oid evtOwner,
 						   Oid funcoid, List *taglist)
 {
 
 	/* Close pg_event_trigger. */
 	heap_close(tgrel, RowExclusiveLock);
+
+	return trigoid;
 }
 
 /*
 /*
  * ALTER EVENT TRIGGER foo ENABLE|DISABLE|ENABLE ALWAYS|REPLICA
  */
-void
+Oid
 AlterEventTrigger(AlterEventTrigStmt *stmt)
 {
 	Relation	tgrel;
 	HeapTuple	tup;
+	Oid         trigoid;
 	Form_pg_event_trigger evtForm;
 	char        tgenabled = stmt->tgenabled;
 
 				(errcode(ERRCODE_UNDEFINED_OBJECT),
 				 errmsg("event trigger \"%s\" does not exist",
 					stmt->trigname)));
-	if (!pg_event_trigger_ownercheck(HeapTupleGetOid(tup), GetUserId()))
+
+	trigoid = HeapTupleGetOid(tup);
+
+	if (!pg_event_trigger_ownercheck(trigoid, GetUserId()))
 		aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_EVENT_TRIGGER,
 					   stmt->trigname);
 
 	/* clean up */
 	heap_freetuple(tup);
 	heap_close(tgrel, RowExclusiveLock);
+
+	return trigoid;
 }
 
 

File src/backend/commands/extension.c

 /*
  * Execute ALTER EXTENSION UPDATE
  */
-void
+Oid
 ExecAlterExtensionStmt(AlterExtensionStmt *stmt)
 {
 	DefElem    *d_new_version = NULL;
 		ereport(NOTICE,
 		   (errmsg("version \"%s\" of extension \"%s\" is already installed",
 				   versionName, stmt->extname)));
-		return;
+		return InvalidOid;
 	}
 
 	/*
 	 */
 	ApplyExtensionUpdates(extensionOid, control,
 						  oldVersionName, updateVersions);
+
+	return extensionOid;
 }
 
 /*
 /*
  * Execute ALTER EXTENSION ADD/DROP
  */
-void
+Oid
 ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt)
 {
 	ObjectAddress extension;
 	 */
 	if (relation != NULL)
 		relation_close(relation, NoLock);
+
+	return extension.objectId;
 }

File src/backend/commands/foreigncmds.c

 /*
  * Create a foreign-data wrapper
  */
-void
+Oid
 CreateForeignDataWrapper(CreateFdwStmt *stmt)
 {
 	Relation	rel;
 						   ForeignDataWrapperRelationId, fdwId, 0, NULL);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return fdwId;
 }
 
 
 /*
  * Alter foreign-data wrapper
  */
-void
+Oid
 AlterForeignDataWrapper(AlterFdwStmt *stmt)
 {
 	Relation	rel;
 	}
 
 	heap_close(rel, RowExclusiveLock);
+
+	return fdwId;
 }
 
 
 /*
  * Create a foreign server
  */
-void
+Oid
 CreateForeignServer(CreateForeignServerStmt *stmt)
 {
 	Relation	rel;
 						   ForeignServerRelationId, srvId, 0, NULL);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return srvId;
 }
 
 
 /*
  * Alter foreign server
  */
-void
+Oid
 AlterForeignServer(AlterForeignServerStmt *stmt)
 {
 	Relation	rel;
 	heap_freetuple(tp);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return srvId;
 }
 
 
 /*
  * Create user mapping
  */
-void
+Oid
 CreateUserMapping(CreateUserMappingStmt *stmt)
 {
 	Relation	rel;
 						   UserMappingRelationId, umId, 0, NULL);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return umId;
 }
 
 
 /*
  * Alter user mapping
  */
-void
+Oid
 AlterUserMapping(AlterUserMappingStmt *stmt)
 {
 	Relation	rel;
 	heap_freetuple(tp);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return umId;
 }
 
 
 /*
  * Drop user mapping
  */
-void
+Oid
 RemoveUserMapping(DropUserMappingStmt *stmt)
 {
 	ObjectAddress object;
 		 * leave.
 		 */
 		elog(NOTICE, "role \"%s\" does not exist, skipping", stmt->username);
-		return;
+		return InvalidOid;
 	}
 
 	if (!srv)
 							stmt->servername)));
 		/* IF EXISTS, just note it */
 		ereport(NOTICE, (errmsg("server does not exist, skipping")));
-		return;
+		return InvalidOid;
 	}
 
 	umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
 		ereport(NOTICE,
 		(errmsg("user mapping \"%s\" does not exist for the server, skipping",
 				MappingUserName(useId))));
-		return;
+		return InvalidOid;
 	}
 
 	user_mapping_ddl_aclcheck(useId, srv->serverid, srv->servername);
 	object.objectSubId = 0;
 
 	performDeletion(&object, DROP_CASCADE, 0);
+
+	return umId;
 }
 
 

File src/backend/commands/functioncmds.c

  * RENAME and OWNER clauses, which are handled as part of the generic
  * ALTER framework).
  */
-void
+Oid
 AlterFunction(AlterFunctionStmt *stmt)
 {
 	HeapTuple	tup;
 
 	heap_close(rel, NoLock);
 	heap_freetuple(tup);
+
+	return funcOid;
 }
 
 /*
 /*
  * CREATE CAST
  */
-void
+Oid
 CreateCast(CreateCastStmt *stmt)
 {
 	Oid			sourcetypeid;
 	heap_freetuple(tuple);
 
 	heap_close(relation, RowExclusiveLock);
+
+	return castid;
 }
 
 /*

File src/backend/commands/indexcmds.c

  * ReindexIndex
  *		Recreate a specific index.
  */
-void
+Oid
 ReindexIndex(RangeVar *indexRelation)
 {
 	Oid			indOid;
 									  (void *) &heapOid);
 
 	reindex_index(indOid, false);
+
+	return indOid;
 }
 
 /*
  * ReindexTable
  *		Recreate all indexes of a table (and of its toast table, if any)
  */
-void
+Oid
 ReindexTable(RangeVar *relation)
 {
 	Oid			heapOid;
 		ereport(NOTICE,
 				(errmsg("table \"%s\" has no indexes",
 						relation->relname)));
+
+	return heapOid;
 }
 
 /*
  * separate transaction, so we can release the lock on it right away.
  * That means this must not be called within a user transaction block!
  */
-void
+Oid
 ReindexDatabase(const char *databaseName, bool do_system, bool do_user)
 {
 	Relation	relationRelation;
 	StartTransactionCommand();
 
 	MemoryContextDelete(private_context);
+
+	return MyDatabaseId;
 }

File src/backend/commands/opclasscmds.c

  * DefineOpClass
  *		Define a new index operator class.
  */
-void
+Oid
 DefineOpClass(CreateOpClassStmt *stmt)
 {
 	char	   *opcname;		/* name of opclass we're creating */
 						   OperatorClassRelationId, opclassoid, 0, NULL);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return opclassoid;
 }
 
 
  * DefineOpFamily
  *		Define a new index operator family.
  */
-void
+Oid
 DefineOpFamily(CreateOpFamilyStmt *stmt)
 {
 	char	   *opfname;		/* name of opfamily we're creating */
 				 errmsg("must be superuser to create an operator family")));
 
 	/* Insert pg_opfamily catalog entry */
-	(void) CreateOpFamily(stmt->amname, opfname, namespaceoid, amoid);
+	return CreateOpFamily(stmt->amname, opfname, namespaceoid, amoid);
 }
 
 
  * other commands called ALTER OPERATOR FAMILY exist, but go through
  * different code paths.
  */
-void
+Oid
 AlterOpFamily(AlterOpFamilyStmt *stmt)
 {
 	Oid			amoid,			/* our AM's oid */
 		AlterOpFamilyAdd(stmt->opfamilyname, amoid, opfamilyoid,
 						 maxOpNumber, maxProcNumber,
 						 stmt->items);
+
+	return opfamilyoid;
 }
 
 /*

File src/backend/commands/proclang.c

 	char	   *tmpllibrary;	/* path of shared library */
 } PLTemplate;
 
-static void create_proc_lang(const char *languageName, bool replace,
-				 Oid languageOwner, Oid handlerOid, Oid inlineOid,
-				 Oid valOid, bool trusted);
+static Oid create_proc_lang(const char *languageName, bool replace,
+							Oid languageOwner, Oid handlerOid, Oid inlineOid,
+							Oid valOid, bool trusted);
 static PLTemplate *find_language_template(const char *languageName);
 
 /* ---------------------------------------------------------------------
  * CREATE PROCEDURAL LANGUAGE
  * ---------------------------------------------------------------------
  */
-void
+Oid
 CreateProceduralLanguage(CreatePLangStmt *stmt)
 {
 	PLTemplate *pltemplate;
 			valOid = InvalidOid;
 
 		/* ok, create it */
-		create_proc_lang(stmt->plname, stmt->replace, GetUserId(),
-						 handlerOid, inlineOid,
-						 valOid, pltemplate->tmpltrusted);
+		return create_proc_lang(stmt->plname, stmt->replace, GetUserId(),
+								handlerOid, inlineOid,
+								valOid, pltemplate->tmpltrusted);
 	}
 	else
 	{
 			valOid = InvalidOid;
 
 		/* ok, create it */
-		create_proc_lang(stmt->plname, stmt->replace, GetUserId(),
-						 handlerOid, inlineOid,
-						 valOid, stmt->pltrusted);
+		return create_proc_lang(stmt->plname, stmt->replace, GetUserId(),
+								handlerOid, inlineOid,
+								valOid, stmt->pltrusted);
 	}
 }
 
 /*
  * Guts of language creation.
  */
-static void
+static Oid
 create_proc_lang(const char *languageName, bool replace,
 				 Oid languageOwner, Oid handlerOid, Oid inlineOid,
 				 Oid valOid, bool trusted)
 						   LanguageRelationId, myself.objectId, 0, NULL);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return myself.objectId;
 }
 
 /*

File src/backend/commands/seclabel.c

  *
  * Apply a security label to a database object.
  */
-void
+Oid
 ExecSecLabelStmt(SecLabelStmt *stmt)
 {
 	LabelProvider *provider = NULL;
 	 */
 	if (relation != NULL)
 		relation_close(relation, NoLock);
+
+	return address.objectId;
 }
 
 /*

File src/backend/commands/tablespace.c

  * since we're determining the system layout and, anyway, we probably have
  * root if we're doing this kind of activity
  */
-void
+Oid
 CreateTableSpace(CreateTableSpaceStmt *stmt)
 {
 #ifdef HAVE_SYMLINK
 			(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
 			 errmsg("tablespaces are not supported on this platform")));
 #endif   /* HAVE_SYMLINK */
+
+	return tablespaceoid;
 }
 
 /*
 /*
  * Alter table space options
  */
-void
+Oid
 AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
 {
 	Relation	rel;
 	ScanKeyData entry[1];
 	HeapScanDesc scandesc;
 	HeapTuple	tup;
+	Oid			tablespaceoid;
 	Datum		datum;
 	Datum		newOptions;
 	Datum		repl_val[Natts_pg_tablespace];
 				 errmsg("tablespace \"%s\" does not exist",
 						stmt->tablespacename)));
 
+	tablespaceoid = HeapTupleGetOid(tup);
+
 	/* Must be owner of the existing object */
 	if (!pg_tablespace_ownercheck(HeapTupleGetOid(tup), GetUserId()))
 		aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TABLESPACE,
 	/* Conclude heap scan. */
 	heap_endscan(scandesc);
 	heap_close(rel, NoLock);
+
+	return tablespaceoid;
 }
 
 /*

File src/backend/commands/tsearchcmds.c

 /*
  * ALTER TEXT SEARCH DICTIONARY
  */
-void
+Oid
 AlterTSDictionary(AlterTSDictionaryStmt *stmt)
 {
 	HeapTuple	tup,
 	ReleaseSysCache(tup);
 
 	heap_close(rel, RowExclusiveLock);
+
+	return dictId;
 }
 
 /* ---------------------- TS Template commands -----------------------*/
 /*
  * ALTER TEXT SEARCH CONFIGURATION - main entry point
  */
-void
+Oid
 AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
 {
 	HeapTuple	tup;
+	Oid			cfgId;
 	Relation	relMap;
 
 	/* Find the configuration */
 				 errmsg("text search configuration \"%s\" does not exist",
 						NameListToString(stmt->cfgname))));
 
+	cfgId = HeapTupleGetOid(tup);
+
 	/* must be owner */
 	if (!pg_ts_config_ownercheck(HeapTupleGetOid(tup), GetUserId()))
 		aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSCONFIGURATION,
 	heap_close(relMap, RowExclusiveLock);
 
 	ReleaseSysCache(tup);
+
+	return cfgId;
 }
 
 /*

File src/backend/commands/typecmds.c

  * DefineEnum
  *		Registers a new enum.
  */
-void
+Oid
 DefineEnum(CreateEnumStmt *stmt)
 {
 	char	   *enumName;
 			   InvalidOid);		/* type's collation */
 
 	pfree(enumArrayName);
+
+	return enumTypeOid;
 }
 
 /*
  * AlterEnum
  *		Adds a new label to an existing enum.
  */
-void
+Oid
 AlterEnum(AlterEnumStmt *stmt, bool isTopLevel)
 {
 	Oid			enum_type_oid;
 				 stmt->skipIfExists);
 
 	ReleaseSysCache(tup);
+
+	return enum_type_oid;
 }
 
 
  * DefineRange
  *		Registers a new range type.
  */
-void
+Oid
 DefineRange(CreateRangeStmt *stmt)
 {
 	char	   *typeName;
 
 	/* And create the constructor functions for this range type */
 	makeRangeConstructors(typeName, typeNamespace, typoid, rangeSubtype);
+
+	return typoid;
 }
 
 /*
  *
  * Routine implementing ALTER DOMAIN SET/DROP DEFAULT statements.
  */
-void
+Oid
 AlterDomainDefault(List *names, Node *defaultRaw)
 {
 	TypeName   *typename;
 	/* Clean up */
 	heap_close(rel, NoLock);
 	heap_freetuple(newtuple);
+
+	return domainoid;
 }
 
 /*
  *
  * Routine implementing ALTER DOMAIN SET/DROP NOT NULL statements.
  */
-void
+Oid
 AlterDomainNotNull(List *names, bool notNull)
 {
 	TypeName   *typename;
 	if (typTup->typnotnull == notNull)
 	{
 		heap_close(typrel, RowExclusiveLock);
-		return;
+		return InvalidOid;
 	}
 
 	/* Adding a NOT NULL constraint requires checking existing columns */
 	/* Clean up */
 	heap_freetuple(tup);
 	heap_close(typrel, RowExclusiveLock);
+
+	return domainoid;
 }
 
 /*
  *
  * Implements the ALTER DOMAIN DROP CONSTRAINT statement
  */
-void
+Oid
 AlterDomainDropConstraint(List *names, const char *constrName,
 						  DropBehavior behavior, bool missing_ok)
 {
 					(errmsg("constraint \"%s\" of domain \"%s\" does not exist, skipping",
 							constrName, TypeNameToString(typename))));
 	}
+
+	return domainoid;
 }
 
 /*
  *
  * Implements the ALTER DOMAIN .. ADD CONSTRAINT statement.
  */
-void
+Oid
 AlterDomainAddConstraint(List *names, Node *newConstraint)
 {
 	TypeName   *typename;
 
 	/* Clean up */
 	heap_close(typrel, RowExclusiveLock);
+
+	return domainoid;
 }
 
 /*
  *
  * Implements the ALTER DOMAIN .. VALIDATE CONSTRAINT statement.
  */
-void
+Oid
 AlterDomainValidateConstraint(List *names, char *constrName)
 {
 	TypeName   *typename;
 	heap_close(conrel, RowExclusiveLock);
 
 	ReleaseSysCache(tup);
+
+	return domainoid;
 }
 
 static void

File src/backend/commands/user.c

 /*
  * CREATE ROLE
  */
-void
+Oid
 CreateRole(CreateRoleStmt *stmt)
 {
 	Relation	pg_authid_rel;
 	 * Close pg_authid, but keep lock till commit.
 	 */
 	heap_close(pg_authid_rel, NoLock);
+
+	return roleid;
 }
 
 
  * backwards-compatible ALTER GROUP syntax.  Although it will work to say
  * "ALTER ROLE role ROLE rolenames", we don't document it.
  */
-void
+Oid
 AlterRole(AlterRoleStmt *stmt)
 {
 	Datum		new_record[Natts_pg_authid];
 	 * Close pg_authid, but keep lock till commit.
 	 */
 	heap_close(pg_authid_rel, NoLock);
+
+	return roleid;
 }
 
 
 /*
  * ALTER ROLE ... SET
  */
-void
+Oid
 AlterRoleSet(AlterRoleSetStmt *stmt)
 {
 	HeapTuple	roletuple;
 	Oid			databaseid = InvalidOid;
+	Oid         roleid;
 
 	roletuple = SearchSysCache1(AUTHNAME, PointerGetDatum(stmt->role));
 
 				(errcode(ERRCODE_UNDEFINED_OBJECT),
 				 errmsg("role \"%s\" does not exist", stmt->role)));
 
+	roleid = HeapTupleGetOid(roletuple);
+
 	/*
 	 * Obtain a lock on the role and make sure it didn't go away in the
 	 * meantime.
 
 	AlterSetting(databaseid, HeapTupleGetOid(roletuple), stmt->setstmt);
 	ReleaseSysCache(roletuple);
+
+	return roleid;
 }
 
 

File src/backend/rewrite/rewriteDefine.c

  * DefineRule
  *		Execute a CREATE RULE command.
  */
-void
+Oid
 DefineRule(RuleStmt *stmt, const char *queryString)
 {
 	List	   *actions;
 	relId = RangeVarGetRelid(stmt->relation, AccessExclusiveLock, false);
 
 	/* ... and execute */
-	DefineQueryRewrite(stmt->rulename,
-					   relId,
-					   whereClause,
-					   stmt->event,
-					   stmt->instead,
-					   stmt->replace,
-					   actions);
+	return DefineQueryRewrite(stmt->rulename,
+							  relId,
+							  whereClause,
+							  stmt->event,
+							  stmt->instead,
+							  stmt->replace,
+							  actions);
 }
 
 
  * This is essentially the same as DefineRule() except that the rule's
  * action and qual have already been passed through parse analysis.
  */
-void
+Oid
 DefineQueryRewrite(char *rulename,
 				   Oid event_relid,
 				   Node *event_qual,
 	ListCell   *l;
 	Query	   *query;
 	bool		RelisBecomingView = false;
+	Oid         ruleId = InvalidOid;
 
 	/*
 	 * If we are installing an ON SELECT rule, we had better grab
 	/* discard rule if it's null action and not INSTEAD; it's a no-op */
 	if (action != NIL || is_instead)
 	{
-		InsertRule(rulename,
-				   event_type,
-				   event_relid,
-				   event_attno,
-				   is_instead,
-				   event_qual,
-				   action,
-				   replace);
+		ruleId = InsertRule(rulename,
+							event_type,
+							event_relid,
+							event_attno,
+							is_instead,
+							event_qual,
+							action,
+							replace);
 
 		/*
 		 * Set pg_class 'relhasrules' field TRUE for event relation. If
 
 	/* Close rel, but keep lock till commit... */
 	heap_close(event_relation, NoLock);
+
+	return ruleId;
 }
 
 /*

File src/backend/tcop/utility.c

 			{
 				uint64		processed;
 
-				processed = DoCopy((CopyStmt *) parsetree, queryString);
+				DoCopy((CopyStmt *) parsetree, queryString, &processed);
 				if (completionTag)
 					snprintf(completionTag, COMPLETION_TAG_BUFSIZE,
 							 "COPY " UINT64_FORMAT, processed);

File src/include/commands/comment.h

  *------------------------------------------------------------------
  */
 
-extern void CommentObject(CommentStmt *stmt);
+extern Oid CommentObject(CommentStmt *stmt);
 
 extern void DeleteComments(Oid oid, Oid classoid, int32 subid);
 

File src/include/commands/copy.h

 /* CopyStateData is private in commands/copy.c */
 typedef struct CopyStateData *CopyState;
 
-extern uint64 DoCopy(const CopyStmt *stmt, const char *queryString);
+extern Oid DoCopy(const CopyStmt *stmt, const char *queryString,
+				  uint64 *processed);
 
 extern void ProcessCopyOptions(CopyState cstate, bool is_from, List *options);
 extern CopyState BeginCopyFrom(Relation rel, const char *filename,

File src/include/commands/dbcommands.h

 	Oid			tablespace_id;
 } xl_dbase_drop_rec;
 
-extern void createdb(const CreatedbStmt *stmt);
+extern Oid createdb(const CreatedbStmt *stmt);
 extern void dropdb(const char *dbname, bool missing_ok);
 extern Oid RenameDatabase(const char *oldname, const char *newname);
-extern void AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel);
-extern void AlterDatabaseSet(AlterDatabaseSetStmt *stmt);
+extern Oid AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel);
+extern Oid AlterDatabaseSet(AlterDatabaseSetStmt *stmt);
 extern Oid AlterDatabaseOwner(const char *dbname, Oid newOwnerId);
 
 extern Oid	get_database_oid(const char *dbname, bool missingok);

File src/include/commands/defrem.h

 			bool check_rights,
 			bool skip_build,
 			bool quiet);
-extern void ReindexIndex(RangeVar *indexRelation);
-extern void ReindexTable(RangeVar *relation);
-extern void ReindexDatabase(const char *databaseName,
+extern Oid ReindexIndex(RangeVar *indexRelation);
+extern Oid ReindexTable(RangeVar *relation);
+extern Oid ReindexDatabase(const char *databaseName,
 				bool do_system, bool do_user);
 extern char *makeObjectName(const char *name1, const char *name2,
 			   const char *label);
 extern void SetFunctionReturnType(Oid funcOid, Oid newRetType);
 extern void SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType);
 extern Oid RenameFunction(List *name, List *argtypes, const char *newname);
-extern void AlterFunction(AlterFunctionStmt *stmt);
-extern void CreateCast(CreateCastStmt *stmt);
+extern Oid AlterFunction(AlterFunctionStmt *stmt);
+extern Oid CreateCast(CreateCastStmt *stmt);
 extern void DropCastById(Oid castOid);
 extern Oid AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
 								  const char *newschema);
 extern Oid RenameAggregate(List *name, List *args, const char *newname);
 
 /* commands/opclasscmds.c */
-extern void DefineOpClass(CreateOpClassStmt *stmt);
-extern void DefineOpFamily(CreateOpFamilyStmt *stmt);
-extern void AlterOpFamily(AlterOpFamilyStmt *stmt);
+extern Oid DefineOpClass(CreateOpClassStmt *stmt);
+extern Oid DefineOpFamily(CreateOpFamilyStmt *stmt);
+extern Oid AlterOpFamily(AlterOpFamilyStmt *stmt);
 extern void RemoveOpClassById(Oid opclassOid);
 extern void RemoveOpFamilyById(Oid opfamilyOid);
 extern void RemoveAmOpEntryById(Oid entryOid);
 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 Oid AlterTSDictionary(AlterTSDictionaryStmt *stmt);
 
 extern Oid DefineTSTemplate(List *names, List *parameters);
 extern Oid RenameTSTemplate(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 Oid AlterTSConfiguration(AlterTSConfigurationStmt *stmt);
 
 extern text *serialize_deflist(List *deflist);
 extern List *deserialize_deflist(Datum txt);
 extern void AlterForeignServerOwner_oid(Oid, 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 CreateForeignDataWrapper(CreateFdwStmt *stmt);
+extern Oid AlterForeignDataWrapper(AlterFdwStmt *stmt);
 extern void RemoveForeignDataWrapperById(Oid fdwId);
-extern void CreateForeignServer(CreateForeignServerStmt *stmt);
-extern void AlterForeignServer(AlterForeignServerStmt *stmt);
+extern Oid CreateForeignServer(CreateForeignServerStmt *stmt);
+extern Oid AlterForeignServer(AlterForeignServerStmt *stmt);
 extern void RemoveForeignServerById(Oid srvId);
-extern void CreateUserMapping(CreateUserMappingStmt *stmt);
-extern void AlterUserMapping(AlterUserMappingStmt *stmt);
-extern void RemoveUserMapping(DropUserMappingStmt *stmt);
+extern Oid CreateUserMapping(CreateUserMappingStmt *stmt);
+extern Oid AlterUserMapping(AlterUserMappingStmt *stmt);
+extern Oid RemoveUserMapping(DropUserMappingStmt *stmt);
 extern void RemoveUserMappingById(Oid umId);
 extern void CreateForeignTable(CreateForeignTableStmt *stmt, Oid relid);
 extern Datum transformGenericOptions(Oid catalogId,

File src/include/commands/event_trigger.h

 #define CALLED_AS_EVENT_TRIGGER(fcinfo) \
 	((fcinfo)->context != NULL && IsA((fcinfo)->context, EventTriggerData))
 
-extern void CreateEventTrigger(CreateEventTrigStmt *stmt);
+extern Oid CreateEventTrigger(CreateEventTrigStmt *stmt);
 extern void RemoveEventTriggerById(Oid ctrigOid);
 extern Oid	get_event_trigger_oid(const char *trigname, bool missing_ok);
 
-extern void AlterEventTrigger(AlterEventTrigStmt *stmt);
+extern Oid AlterEventTrigger(AlterEventTrigStmt *stmt);
 extern Oid RenameEventTrigger(const char* trigname, const char *newname);
 extern Oid AlterEventTriggerOwner(const char *name, Oid newOwnerId);
 extern void AlterEventTriggerOwner_oid(Oid, Oid newOwnerId);

File src/include/commands/extension.h

 					 Datum extConfig, Datum extCondition,
 					 List *requiredExtensions);
 
-extern void ExecAlterExtensionStmt(AlterExtensionStmt *stmt);
+extern Oid ExecAlterExtensionStmt(AlterExtensionStmt *stmt);
 
-extern void ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt);
+extern Oid ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt);
 
 extern Oid	get_extension_oid(const char *extname, bool missing_ok);
 extern char *get_extension_name(Oid ext_oid);

File src/include/commands/proclang.h

 
 #include "nodes/parsenodes.h"
 
-extern void CreateProceduralLanguage(CreatePLangStmt *stmt);
+extern Oid CreateProceduralLanguage(CreatePLangStmt *stmt);
 extern void DropProceduralLanguageById(Oid langOid);
 extern Oid RenameLanguage(const char *oldname, const char *newname);
 extern bool PLTemplateExists(const char *languageName);

File src/include/commands/seclabel.h

 /*
  * Statement and ESP hook support
  */
-extern void ExecSecLabelStmt(SecLabelStmt *stmt);
+extern Oid ExecSecLabelStmt(SecLabelStmt *stmt);
 
 typedef void (*check_object_relabel_type) (const ObjectAddress *object,
 													   const char *seclabel);

File src/include/commands/tablespace.h

 	float8		seq_page_cost;
 } TableSpaceOpts;
 
-extern void CreateTableSpace(CreateTableSpaceStmt *stmt);
+extern Oid CreateTableSpace(CreateTableSpaceStmt *stmt);
 extern void DropTableSpace(DropTableSpaceStmt *stmt);
 extern Oid RenameTableSpace(const char *oldname, const char *newname);
-extern void AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt);
+extern Oid AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt);
 
 extern void TablespaceCreateDbspace(Oid spcNode, Oid dbNode, bool isRedo);
 

File src/include/commands/typecmds.h

 extern Oid DefineType(List *names, List *parameters);
 extern void RemoveTypeById(Oid typeOid);
 extern Oid DefineDomain(CreateDomainStmt *stmt);
-extern void DefineEnum(CreateEnumStmt *stmt);
-extern void DefineRange(CreateRangeStmt *stmt);
-extern void AlterEnum(AlterEnumStmt *stmt, bool isTopLevel);
+extern Oid DefineEnum(CreateEnumStmt *stmt);
+extern Oid DefineRange(CreateRangeStmt *stmt);
+extern Oid AlterEnum(AlterEnumStmt *stmt, bool isTopLevel);
 extern Oid	DefineCompositeType(RangeVar *typevar, List *coldeflist);
 extern Oid	AssignTypeArrayOid(void);
 
-extern void AlterDomainDefault(List *names, Node *defaultRaw);
-extern void AlterDomainNotNull(List *names, bool notNull);
-extern void AlterDomainAddConstraint(List *names, Node *constr);
-extern void AlterDomainValidateConstraint(List *names, char *constrName);
-extern void AlterDomainDropConstraint(List *names, const char *constrName,
+extern Oid AlterDomainDefault(List *names, Node *defaultRaw);
+extern Oid AlterDomainNotNull(List *names, bool notNull);
+extern Oid AlterDomainAddConstraint(List *names, Node *constr);
+extern Oid AlterDomainValidateConstraint(List *names, char *constrName);
+extern Oid AlterDomainDropConstraint(List *names, const char *constrName,
 						  DropBehavior behavior, bool missing_ok);
 
 extern void checkDomainOwner(HeapTuple tup);

File src/include/commands/user.h

 
 extern PGDLLIMPORT check_password_hook_type check_password_hook;
 
-extern void CreateRole(CreateRoleStmt *stmt);
-extern void AlterRole(AlterRoleStmt *stmt);
-extern void AlterRoleSet(AlterRoleSetStmt *stmt);
+extern Oid CreateRole(CreateRoleStmt *stmt);
+extern Oid AlterRole(AlterRoleStmt *stmt);
+extern Oid AlterRoleSet(AlterRoleSetStmt *stmt);
 extern void DropRole(DropRoleStmt *stmt);
 extern void GrantRole(GrantRoleStmt *stmt);
 extern Oid RenameRole(const char *oldname, const char *newname);

File src/include/rewrite/rewriteDefine.h

 #define RULE_FIRES_ON_REPLICA	'R'
 #define RULE_DISABLED			'D'
 
-extern void DefineRule(RuleStmt *stmt, const char *queryString);
+extern Oid DefineRule(RuleStmt *stmt, const char *queryString);
 
-extern void DefineQueryRewrite(char *rulename,
+extern Oid DefineQueryRewrite(char *rulename,
 				   Oid event_relid,
 				   Node *event_qual,
 				   CmdType event_type,