long count);
static void pgss_ExecutorFinish(QueryDesc *queryDesc);
static void pgss_ExecutorEnd(QueryDesc *queryDesc);
-static void pgss_ProcessUtility(Node *parsetree,
- const char *queryString, ParamListInfo params,
- DestReceiver *dest, char *completionTag,
- ProcessUtilityContext context);
+static void pgss_ProcessUtility(Node *parsetree, const char *queryString,
+ ProcessUtilityContext context, ParamListInfo params,
+ DestReceiver *dest, char *completionTag);
static uint32 pgss_hash_fn(const void *key, Size keysize);
static int pgss_match_fn(const void *key1, const void *key2, Size keysize);
static uint32 pgss_hash_string(const char *str);
*/
static void
pgss_ProcessUtility(Node *parsetree, const char *queryString,
- ParamListInfo params, DestReceiver *dest,
- char *completionTag, ProcessUtilityContext context)
+ ProcessUtilityContext context, ParamListInfo params,
+ DestReceiver *dest, char *completionTag)
{
/*
* If it's an EXECUTE statement, we don't track it and don't increment the
PG_TRY();
{
if (prev_ProcessUtility)
- prev_ProcessUtility(parsetree, queryString, params,
- dest, completionTag, context);
+ prev_ProcessUtility(parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
- standard_ProcessUtility(parsetree, queryString, params,
- dest, completionTag, context);
+ standard_ProcessUtility(parsetree, queryString,
+ context, params,
+ dest, completionTag);
nested_level--;
}
PG_CATCH();
else
{
if (prev_ProcessUtility)
- prev_ProcessUtility(parsetree, queryString, params,
- dest, completionTag, context);
+ prev_ProcessUtility(parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
- standard_ProcessUtility(parsetree, queryString, params,
- dest, completionTag, context);
+ standard_ProcessUtility(parsetree, queryString,
+ context, params,
+ dest, completionTag);
}
}
static void
sepgsql_utility_command(Node *parsetree,
const char *queryString,
+ ProcessUtilityContext context,
ParamListInfo params,
DestReceiver *dest,
- char *completionTag,
- ProcessUtilityContext context)
+ char *completionTag)
{
sepgsql_context_info_t saved_context_info = sepgsql_context_info;
ListCell *cell;
}
if (next_ProcessUtility_hook)
- (*next_ProcessUtility_hook) (parsetree, queryString, params,
- dest, completionTag, context);
+ (*next_ProcessUtility_hook) (parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
- standard_ProcessUtility(parsetree, queryString, params,
- dest, completionTag, context);
+ standard_ProcessUtility(parsetree, queryString,
+ context, params,
+ dest, completionTag);
}
PG_CATCH();
{
{
ProcessUtility(stmt,
sql,
+ PROCESS_UTILITY_QUERY,
NULL,
dest,
- NULL,
- PROCESS_UTILITY_QUERY);
+ NULL);
}
PopActiveSnapshot();
/* do this step */
ProcessUtility(stmt,
queryString,
+ PROCESS_UTILITY_SUBCOMMAND,
NULL,
None_Receiver,
- NULL,
- PROCESS_UTILITY_SUBCOMMAND);
+ NULL);
/* make sure later steps can see the object created here */
CommandCounterIncrement();
}
/* ... and execute it */
ProcessUtility((Node *) atstmt,
"(generated ALTER TABLE ADD FOREIGN KEY command)",
- NULL, None_Receiver, NULL, PROCESS_UTILITY_GENERATED);
+ PROCESS_UTILITY_SUBCOMMAND, NULL,
+ None_Receiver, NULL);
/* Remove the matched item from the list */
info_list = list_delete_ptr(info_list, info);
(Node *) es->qd->plannedstmt :
es->qd->utilitystmt),
fcache->src,
+ PROCESS_UTILITY_QUERY,
es->qd->params,
es->qd->dest,
- NULL,
- PROCESS_UTILITY_QUERY);
+ NULL);
result = true; /* never stops early */
}
else
ProcessUtility(stmt,
plansource->query_string,
+ PROCESS_UTILITY_QUERY,
paramLI,
dest,
- completionTag,
- PROCESS_UTILITY_QUERY);
+ completionTag);
/* Update "processed" if stmt returned tuples */
if (_SPI_current->tuptable)
ProcessUtility(utilityStmt,
portal->sourceText,
+ isTopLevel ? PROCESS_UTILITY_TOPLEVEL : PROCESS_UTILITY_QUERY,
portal->portalParams,
dest,
- completionTag,
- isTopLevel ?
- PROCESS_UTILITY_TOPLEVEL : PROCESS_UTILITY_QUERY);
+ completionTag);
/* Some utility statements may change context on us */
MemoryContextSwitchTo(PortalGetHeapMemory(portal));
/* local function declarations */
static void ProcessUtilitySlow(Node *parsetree,
const char *queryString,
+ ProcessUtilityContext context,
ParamListInfo params,
DestReceiver *dest,
- char *completionTag,
- ProcessUtilityContext context);
+ char *completionTag);
static void ExecDropStmt(DropStmt *stmt, bool isTopLevel);
*
* parsetree: the parse tree for the utility statement
* queryString: original source text of command
+ * context: identifies source of statement (toplevel client command,
+ * non-toplevel client command, subcommand of a larger utility command)
* params: parameters to use during execution
- * isTopLevel: true if executing a "top level" (interactively issued) command
* dest: where to send results
* completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE
* in which to store a command completion status string.
void
ProcessUtility(Node *parsetree,
const char *queryString,
+ ProcessUtilityContext context,
ParamListInfo params,
DestReceiver *dest,
- char *completionTag,
- ProcessUtilityContext context)
+ char *completionTag)
{
Assert(queryString != NULL); /* required as of 8.4 */
* call standard_ProcessUtility().
*/
if (ProcessUtility_hook)
- (*ProcessUtility_hook) (parsetree, queryString, params,
- dest, completionTag, context);
+ (*ProcessUtility_hook) (parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
- standard_ProcessUtility(parsetree, queryString, params,
- dest, completionTag, context);
+ standard_ProcessUtility(parsetree, queryString,
+ context, params,
+ dest, completionTag);
}
/*
void
standard_ProcessUtility(Node *parsetree,
const char *queryString,
+ ProcessUtilityContext context,
ParamListInfo params,
DestReceiver *dest,
- char *completionTag,
- ProcessUtilityContext context)
+ char *completionTag)
{
bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL);
DropStmt *stmt = (DropStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->removeType))
- ProcessUtilitySlow(parsetree, queryString, params,
- dest, completionTag, context);
+ ProcessUtilitySlow(parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
ExecDropStmt(stmt, isTopLevel);
}
RenameStmt *stmt = (RenameStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->renameType))
- ProcessUtilitySlow(parsetree, queryString, params,
- dest, completionTag, context);
+ ProcessUtilitySlow(parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
ExecRenameStmt(stmt);
}
AlterObjectSchemaStmt *stmt = (AlterObjectSchemaStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->objectType))
- ProcessUtilitySlow(parsetree, queryString, params,
- dest, completionTag, context);
+ ProcessUtilitySlow(parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
ExecAlterObjectSchemaStmt(stmt);
}
AlterOwnerStmt *stmt = (AlterOwnerStmt *) parsetree;
if (EventTriggerSupportsObjectType(stmt->objectType))
- ProcessUtilitySlow(parsetree, queryString, params,
- dest, completionTag, context);
+ ProcessUtilitySlow(parsetree, queryString,
+ context, params,
+ dest, completionTag);
else
ExecAlterOwnerStmt(stmt);
}
default:
/* All other statement types have event trigger support */
- ProcessUtilitySlow(parsetree, queryString, params,
- dest, completionTag, context);
+ ProcessUtilitySlow(parsetree, queryString,
+ context, params,
+ dest, completionTag);
break;
}
}
static void
ProcessUtilitySlow(Node *parsetree,
const char *queryString,
+ ProcessUtilityContext context,
ParamListInfo params,
DestReceiver *dest,
- char *completionTag,
- ProcessUtilityContext context)
+ char *completionTag)
{
bool isTopLevel = (context == PROCESS_UTILITY_TOPLEVEL);
bool isCompleteQuery = (context <= PROCESS_UTILITY_QUERY);
/* Recurse for anything else */
ProcessUtility(stmt,
queryString,
+ PROCESS_UTILITY_SUBCOMMAND,
params,
None_Receiver,
- NULL,
- PROCESS_UTILITY_GENERATED);
+ NULL);
}
/* Need CCI between commands */
/* Recurse for anything else */
ProcessUtility(stmt,
queryString,
+ PROCESS_UTILITY_SUBCOMMAND,
params,
None_Receiver,
- NULL,
- PROCESS_UTILITY_GENERATED);
+ NULL);
}
/* Need CCI between commands */
{
PROCESS_UTILITY_TOPLEVEL, /* toplevel interactive command */
PROCESS_UTILITY_QUERY, /* a complete query, but not toplevel */
- PROCESS_UTILITY_SUBCOMMAND, /* a piece of a query */
- PROCESS_UTILITY_GENERATED /* internally generated node query node */
+ PROCESS_UTILITY_SUBCOMMAND /* a portion of a query */
} ProcessUtilityContext;
/* Hook for plugins to get control in ProcessUtility() */
typedef void (*ProcessUtility_hook_type) (Node *parsetree,
- const char *queryString, ParamListInfo params,
- DestReceiver *dest, char *completionTag,
- ProcessUtilityContext context);
+ const char *queryString, ProcessUtilityContext context,
+ ParamListInfo params,
+ DestReceiver *dest, char *completionTag);
extern PGDLLIMPORT ProcessUtility_hook_type ProcessUtility_hook;
extern void ProcessUtility(Node *parsetree, const char *queryString,
- ParamListInfo params, DestReceiver *dest, char *completionTag,
- ProcessUtilityContext context);
+ ProcessUtilityContext context, ParamListInfo params,
+ DestReceiver *dest, char *completionTag);
extern void standard_ProcessUtility(Node *parsetree, const char *queryString,
- ParamListInfo params, DestReceiver *dest,
- char *completionTag, ProcessUtilityContext context);
+ ProcessUtilityContext context, ParamListInfo params,
+ DestReceiver *dest, char *completionTag);
extern bool UtilityReturnsTuples(Node *parsetree);