]> granicus.if.org Git - postgresql/blob - src/include/tcop/tcopprot.h
Add hooks for session start and session end
[postgresql] / src / include / tcop / tcopprot.h
1 /*-------------------------------------------------------------------------
2  *
3  * tcopprot.h
4  *        prototypes for postgres.c.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/tcop/tcopprot.h
11  *
12  * OLD COMMENTS
13  *        This file was created so that other c files could get the two
14  *        function prototypes without having to include tcop.h which single
15  *        handedly includes the whole f*cking tree -- mer 5 Nov. 1991
16  *
17  *-------------------------------------------------------------------------
18  */
19 #ifndef TCOPPROT_H
20 #define TCOPPROT_H
21
22 #include "nodes/params.h"
23 #include "nodes/parsenodes.h"
24 #include "nodes/plannodes.h"
25 #include "storage/procsignal.h"
26 #include "utils/guc.h"
27 #include "utils/queryenvironment.h"
28
29
30 /* Required daylight between max_stack_depth and the kernel limit, in bytes */
31 #define STACK_DEPTH_SLOP (512 * 1024L)
32
33 extern CommandDest whereToSendOutput;
34 extern PGDLLIMPORT const char *debug_query_string;
35 extern int      max_stack_depth;
36 extern int      PostAuthDelay;
37
38 /* Hook for plugins to get control at start and end of session */
39 typedef void (*session_start_hook_type) (void);
40 typedef void (*session_end_hook_type) (void);
41
42 extern PGDLLIMPORT session_start_hook_type session_start_hook;
43 extern PGDLLIMPORT session_end_hook_type session_end_hook;
44
45 /* GUC-configurable parameters */
46
47 typedef enum
48 {
49         LOGSTMT_NONE,                           /* log no statements */
50         LOGSTMT_DDL,                            /* log data definition statements */
51         LOGSTMT_MOD,                            /* log modification statements, plus DDL */
52         LOGSTMT_ALL                                     /* log all statements */
53 } LogStmtLevel;
54
55 extern int      log_statement;
56
57 extern List *pg_parse_query(const char *query_string);
58 extern List *pg_analyze_and_rewrite(RawStmt *parsetree,
59                                            const char *query_string,
60                                            Oid *paramTypes, int numParams,
61                                            QueryEnvironment *queryEnv);
62 extern List *pg_analyze_and_rewrite_params(RawStmt *parsetree,
63                                                           const char *query_string,
64                                                           ParserSetupHook parserSetup,
65                                                           void *parserSetupArg,
66                                                           QueryEnvironment *queryEnv);
67 extern PlannedStmt *pg_plan_query(Query *querytree, int cursorOptions,
68                           ParamListInfo boundParams);
69 extern List *pg_plan_queries(List *querytrees, int cursorOptions,
70                                 ParamListInfo boundParams);
71
72 extern bool check_max_stack_depth(int *newval, void **extra, GucSource source);
73 extern void assign_max_stack_depth(int newval, void *extra);
74
75 extern void die(SIGNAL_ARGS);
76 extern void quickdie(SIGNAL_ARGS) pg_attribute_noreturn();
77 extern void StatementCancelHandler(SIGNAL_ARGS);
78 extern void FloatExceptionHandler(SIGNAL_ARGS) pg_attribute_noreturn();
79 extern void RecoveryConflictInterrupt(ProcSignalReason reason); /* called from SIGUSR1
80                                                                                                                                  * handler */
81 extern void ProcessClientReadInterrupt(bool blocked);
82 extern void ProcessClientWriteInterrupt(bool blocked);
83
84 extern void process_postgres_switches(int argc, char *argv[],
85                                                   GucContext ctx, const char **dbname);
86 extern void PostgresMain(int argc, char *argv[],
87                          const char *dbname,
88                          const char *username) pg_attribute_noreturn();
89 extern long get_stack_depth_rlimit(void);
90 extern void ResetUsage(void);
91 extern void ShowUsage(const char *title);
92 extern int      check_log_duration(char *msec_str, bool was_logged);
93 extern void set_debug_options(int debug_flag,
94                                   GucContext context, GucSource source);
95 extern bool set_plan_disabling_options(const char *arg,
96                                                    GucContext context, GucSource source);
97 extern const char *get_stats_option_name(const char *arg);
98
99 #endif                                                  /* TCOPPROT_H */