1 /*-------------------------------------------------------------------------
2  *
3  * utility.h
4  *	  prototypes for utility.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/tcop/utility.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef UTILITY_H
15 #define UTILITY_H
16 
17 #include "tcop/tcopprot.h"
18 
19 typedef enum
20 {
21 	PROCESS_UTILITY_TOPLEVEL,	/* toplevel interactive command */
22 	PROCESS_UTILITY_QUERY,		/* a complete query, but not toplevel */
23 	PROCESS_UTILITY_QUERY_NONATOMIC,	/* a complete query, nonatomic
24 										 * execution context */
main(String[] args)25 	PROCESS_UTILITY_SUBCOMMAND	/* a portion of a query */
26 } ProcessUtilityContext;
27 
28 /* Hook for plugins to get control in ProcessUtility() */
29 typedef void (*ProcessUtility_hook_type) (PlannedStmt *pstmt,
30 										  const char *queryString, ProcessUtilityContext context,
31 										  ParamListInfo params,
32 										  QueryEnvironment *queryEnv,
33 										  DestReceiver *dest, char *completionTag);
34 extern PGDLLIMPORT ProcessUtility_hook_type ProcessUtility_hook;
35 
36 extern void ProcessUtility(PlannedStmt *pstmt, const char *queryString,
37 						   ProcessUtilityContext context, ParamListInfo params,
38 						   QueryEnvironment *queryEnv,
39 						   DestReceiver *dest, char *completionTag);
40 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
41 									ProcessUtilityContext context, ParamListInfo params,
42 									QueryEnvironment *queryEnv,
43 									DestReceiver *dest, char *completionTag);
44 
45 extern bool UtilityReturnsTuples(Node *parsetree);
46 
47 extern TupleDesc UtilityTupleDescriptor(Node *parsetree);
48 
49 extern Query *UtilityContainsQuery(Node *parsetree);
50 
51 extern const char *CreateCommandTag(Node *parsetree);
52 
53 extern LogStmtLevel GetCommandLogLevel(Node *parsetree);
54 
55 extern bool CommandIsReadOnly(PlannedStmt *pstmt);
56 
57 #endif							/* UTILITY_H */
58