guc_tables.h 6.2 KB
Newer Older
1 2 3 4 5 6 7
/*-------------------------------------------------------------------------
 *
 * guc_tables.h
 *		Declarations of tables used by GUC.
 *
 * See src/backend/utils/misc/README for design notes.
 *
8
 * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
9
 *
10
 *	  $PostgreSQL: pgsql/src/include/utils/guc_tables.h,v 1.32 2007/03/13 14:32:25 petere Exp $
11 12 13
 *
 *-------------------------------------------------------------------------
 */
14 15 16
#ifndef GUC_TABLES_H
#define GUC_TABLES_H 1

17 18
#include "utils/guc.h"

19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
/*
 * GUC supports these types of variables:
 */
enum config_type
{
	PGC_BOOL,
	PGC_INT,
	PGC_REAL,
	PGC_STRING
};

union config_var_value
{
	bool		boolval;
	int			intval;
	double		realval;
	char	   *stringval;
};
37 38

/*
39
 * Groupings to help organize all the run-time options for display
40 41 42 43
 */
enum config_group
{
	UNGROUPED,
44
	FILE_LOCATIONS,
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
	CONN_AUTH,
	CONN_AUTH_SETTINGS,
	CONN_AUTH_SECURITY,
	RESOURCES,
	RESOURCES_MEM,
	RESOURCES_FSM,
	RESOURCES_KERNEL,
	WAL,
	WAL_SETTINGS,
	WAL_CHECKPOINTS,
	QUERY_TUNING,
	QUERY_TUNING_METHOD,
	QUERY_TUNING_COST,
	QUERY_TUNING_GEQO,
	QUERY_TUNING_OTHER,
	LOGGING,
61
	LOGGING_WHERE,
62 63 64 65 66
	LOGGING_WHEN,
	LOGGING_WHAT,
	STATS,
	STATS_MONITORING,
	STATS_COLLECTOR,
67
	AUTOVACUUM,
68 69 70 71 72 73 74 75
	CLIENT_CONN,
	CLIENT_CONN_STATEMENT,
	CLIENT_CONN_LOCALE,
	CLIENT_CONN_OTHER,
	LOCK_MANAGEMENT,
	COMPAT_OPTIONS,
	COMPAT_OPTIONS_PREVIOUS,
	COMPAT_OPTIONS_CLIENT,
76 77 78
	PRESET_OPTIONS,
	CUSTOM_OPTIONS,
	DEVELOPER_OPTIONS
79 80 81
};

/*
82 83
 * Stack entry for saving the state of a variable prior to the current
 * transaction
84
 */
85
typedef struct guc_stack
86
{
87 88 89 90 91
	struct guc_stack *prev;		/* previous stack item, if any */
	int			nest_level;		/* nesting depth of cur transaction */
	int			status;			/* previous status bits, see below */
	GucSource	tentative_source;		/* source of the tentative_value */
	GucSource	source;			/* source of the actual value */
B
Bruce Momjian 已提交
92 93
	union config_var_value tentative_val;		/* previous tentative val */
	union config_var_value value;		/* previous actual value */
94
} GucStack;
95 96 97 98 99

/*
 * Generic fields applicable to all types of variables
 *
 * The short description should be less than 80 chars in length. Some
B
Bruce Momjian 已提交
100 101
 * applications may use the long description as well, and will append
 * it to the short description. (separated by a newline or '. ')
102 103 104 105 106 107
 */
struct config_generic
{
	/* constant fields, must be set correctly in initial value: */
	const char *name;			/* name of variable - MUST BE FIRST */
	GucContext	context;		/* context required to set the variable */
B
Bruce Momjian 已提交
108 109 110
	enum config_group group;	/* to help organize variables by function */
	const char *short_desc;		/* short desc. of this variable's purpose */
	const char *long_desc;		/* long desc. of this variable's purpose */
111 112 113 114 115 116 117
	int			flags;			/* flag bits, see below */
	/* variable fields, initialized at runtime: */
	enum config_type vartype;	/* type of variable (set only at startup) */
	int			status;			/* status bits, see below */
	GucSource	reset_source;	/* source of the reset_value */
	GucSource	tentative_source;		/* source of the tentative_value */
	GucSource	source;			/* source of the current actual value */
118
	GucStack   *stack;			/* stacked outside-of-transaction states */
119 120 121 122 123 124 125 126
};

/* bit values in flags field */
#define GUC_LIST_INPUT			0x0001	/* input can be list format */
#define GUC_LIST_QUOTE			0x0002	/* double-quote list elements */
#define GUC_NO_SHOW_ALL			0x0004	/* exclude from SHOW ALL */
#define GUC_NO_RESET_ALL		0x0008	/* exclude from RESET ALL */
#define GUC_REPORT				0x0010	/* auto-report changes to client */
B
Bruce Momjian 已提交
127 128
#define GUC_NOT_IN_SAMPLE		0x0020	/* not in postgresql.conf.sample */
#define GUC_DISALLOW_IN_FILE	0x0040	/* can't set in postgresql.conf */
129 130
#define GUC_CUSTOM_PLACEHOLDER	0x0080	/* placeholder for custom variable */
#define GUC_SUPERUSER_ONLY		0x0100	/* show only to superusers */
131
#define GUC_IS_NAME				0x0200	/* limit string to NAMEDATALEN-1 */
132

133 134
#define GUC_UNIT_KB				0x0400	/* value is in 1 kB */
#define GUC_UNIT_BLOCKS			0x0800	/* value is in blocks */
135 136
#define GUC_UNIT_XBLOCKS		0x0C00	/* value is in xlog blocks */
#define GUC_UNIT_MEMORY			0x0C00	/* mask for KB, BLOCKS, XBLOCKS */
137 138 139 140

#define GUC_UNIT_MS				0x1000	/* value is in milliseconds */
#define GUC_UNIT_S				0x2000	/* value is in seconds */
#define GUC_UNIT_MIN			0x4000	/* value is in minutes */
141
#define GUC_UNIT_TIME			0x7000	/* mask for MS, S, MIN */
142

143 144 145
/* bit values in status field */
#define GUC_HAVE_TENTATIVE	0x0001		/* tentative value is defined */
#define GUC_HAVE_LOCAL		0x0002		/* a SET LOCAL has been executed */
146
#define GUC_HAVE_STACK		0x0004		/* we have stacked prior value(s) */
147

148 149 150 151 152 153 154 155 156

/* GUC records for specific variable types */

struct config_bool
{
	struct config_generic gen;
	/* these fields must be set correctly in initial value: */
	/* (all but reset_val are constants) */
	bool	   *variable;
157
	bool		reset_val;
158 159
	GucBoolAssignHook assign_hook;
	GucShowHook show_hook;
160 161 162 163 164 165 166 167 168 169
	/* variable fields, initialized at runtime: */
	bool		tentative_val;
};

struct config_int
{
	struct config_generic gen;
	/* these fields must be set correctly in initial value: */
	/* (all but reset_val are constants) */
	int		   *variable;
170
	int			reset_val;
171 172
	int			min;
	int			max;
173 174
	GucIntAssignHook assign_hook;
	GucShowHook show_hook;
175 176 177 178 179 180 181 182 183 184
	/* variable fields, initialized at runtime: */
	int			tentative_val;
};

struct config_real
{
	struct config_generic gen;
	/* these fields must be set correctly in initial value: */
	/* (all but reset_val are constants) */
	double	   *variable;
185
	double		reset_val;
186 187
	double		min;
	double		max;
188 189
	GucRealAssignHook assign_hook;
	GucShowHook show_hook;
190 191 192 193 194 195 196 197 198 199 200
	/* variable fields, initialized at runtime: */
	double		tentative_val;
};

struct config_string
{
	struct config_generic gen;
	/* these fields must be set correctly in initial value: */
	/* (all are constants) */
	char	  **variable;
	const char *boot_val;
201 202
	GucStringAssignHook assign_hook;
	GucShowHook show_hook;
203 204 205 206 207
	/* variable fields, initialized at runtime: */
	char	   *reset_val;
	char	   *tentative_val;
};

208
/* constant tables corresponding to enums above and in guc.h */
B
Bruce Momjian 已提交
209 210 211 212
extern const char *const config_group_names[];
extern const char *const config_type_names[];
extern const char *const GucContext_Names[];
extern const char *const GucSource_Names[];
213

214 215
/* get the current set of variables */
extern struct config_generic **get_guc_variables(void);
216 217 218

extern void build_guc_variables(void);

B
Bruce Momjian 已提交
219
#endif   /* GUC_TABLES_H */