#ifndef UTILITY_H
#define UTILITY_H
#include "tcop/cmdtag.h"
#include "tcop/tcopprot.h"
typedef enum
{
PROCESS_UTILITY_TOPLEVEL,
PROCESS_UTILITY_QUERY,
PROCESS_UTILITY_QUERY_NONATOMIC,
PROCESS_UTILITY_SUBCOMMAND,
} ProcessUtilityContext;
typedef struct AlterTableUtilityContext
{
PlannedStmt *pstmt;
const char *queryString;
Oid relid;
ParamListInfo params;
QueryEnvironment *queryEnv;
} AlterTableUtilityContext;
#define COMMAND_OK_IN_READ_ONLY_TXN 0x0001
#define COMMAND_OK_IN_PARALLEL_MODE 0x0002
#define COMMAND_OK_IN_RECOVERY 0x0004
#define COMMAND_IS_STRICTLY_READ_ONLY \
(COMMAND_OK_IN_READ_ONLY_TXN | COMMAND_OK_IN_RECOVERY | \
COMMAND_OK_IN_PARALLEL_MODE)
#define COMMAND_IS_NOT_READ_ONLY 0
typedef void (*ProcessUtility_hook_type) (PlannedStmt *pstmt,
const char *queryString,
bool readOnlyTree,
ProcessUtilityContext context,
ParamListInfo params,
QueryEnvironment *queryEnv,
DestReceiver *dest, QueryCompletion *qc);
extern PGDLLIMPORT ProcessUtility_hook_type ProcessUtility_hook;
extern void ProcessUtility(PlannedStmt *pstmt, const char *queryString,
bool readOnlyTree,
ProcessUtilityContext context, ParamListInfo params,
QueryEnvironment *queryEnv,
DestReceiver *dest, QueryCompletion *qc);
extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
bool readOnlyTree,
ProcessUtilityContext context, ParamListInfo params,
QueryEnvironment *queryEnv,
DestReceiver *dest, QueryCompletion *qc);
extern void ProcessUtilityForAlterTable(Node *stmt,
AlterTableUtilityContext *context);
extern bool UtilityReturnsTuples(Node *parsetree);
extern TupleDesc UtilityTupleDescriptor(Node *parsetree);
extern Query *UtilityContainsQuery(Node *parsetree);
extern CommandTag CreateCommandTag(Node *parsetree);
static inline const char *
CreateCommandName(Node *parsetree)
{
return GetCommandTagName(CreateCommandTag(parsetree));
}
extern LogStmtLevel GetCommandLogLevel(Node *parsetree);
extern bool CommandIsReadOnly(PlannedStmt *pstmt);
#endif