1 /* -*-pgsql-c-*- */ 2 /* 3 * 4 * pgpool: a language independent connection pool server for PostgreSQL 5 * written by Tatsuo Ishii 6 * 7 * Copyright (c) 2003-2020 PgPool Global Development Group 8 * 9 * Permission to use, copy, modify, and distribute this software and 10 * its documentation for any purpose and without fee is hereby 11 * granted, provided that the above copyright notice appear in all 12 * copies and that both that copyright notice and this permission 13 * notice appear in supporting documentation, and that the name of the 14 * author not be used in advertising or publicity pertaining to 15 * distribution of the software without specific, written prior 16 * permission. The author makes no representations about the 17 * suitability of this software for any purpose. It is provided "as 18 * is" without express or implied warranty. 19 * 20 * pool_config_variables.h. 21 * 22 */ 23 24 #ifndef POOL_CONFIG_VARIABLES_H 25 #define POOL_CONFIG_VARIABLES_H 26 27 28 typedef enum 29 { 30 CONNECTION_CONFIG, 31 CONNECTION_POOL_CONFIG, 32 LOGGING_CONFIG, 33 HEALTH_CHECK_CONFIG, 34 FILE_LOCATION_CONFIG, 35 LOAD_BALANCE_CONFIG, 36 REPLICATION_CONFIG, 37 STREAMING_REPLICATION_CONFIG, 38 MAIN_REPLICA_CONFIG, 39 WATCHDOG_CONFIG, 40 SSL_CONFIG, 41 FAILOVER_CONFIG, 42 RECOVERY_CONFIG, 43 WATCHDOG_LIFECHECK, 44 GENERAL_CONFIG, 45 CACHE_CONFIG 46 } config_group; 47 48 typedef enum 49 { 50 CONFIG_VAR_TYPE_BOOL, 51 CONFIG_VAR_TYPE_INT, 52 CONFIG_VAR_TYPE_LONG, 53 CONFIG_VAR_TYPE_DOUBLE, 54 CONFIG_VAR_TYPE_STRING, 55 CONFIG_VAR_TYPE_STRING_LIST, 56 CONFIG_VAR_TYPE_ENUM, 57 CONFIG_VAR_TYPE_INT_ARRAY, 58 CONFIG_VAR_TYPE_DOUBLE_ARRAY, 59 CONFIG_VAR_TYPE_STRING_ARRAY, 60 CONFIG_VAR_TYPE_GROUP 61 } config_type; 62 63 /* 64 * The possible values of an enum variable are specified by an array of 65 * name-value pairs. The "hidden" flag means the value is accepted but 66 * won't be displayed when guc.c is asked for a list of acceptable values. 67 */ 68 struct config_enum_entry 69 { 70 const char *name; 71 int val; 72 bool hidden; 73 }; 74 75 typedef enum 76 { 77 PGC_S_DEFAULT, /* hard-wired default ("boot_val") */ 78 PGC_S_FILE, /* pgpool.conf */ 79 PGC_S_ARGV, /* command line */ 80 PGC_S_CLIENT, /* from client connection request */ 81 PGC_S_SESSION, /* SET command */ 82 PGC_S_VALUE_DEFAULT /* Configurable Default Value for array type */ 83 } GucSource; 84 85 86 /* Config variable flags bit values */ 87 #define VAR_PART_OF_GROUP 0x0001 88 #define VAR_HIDDEN_VALUE 0x0002 /* for password type variables */ 89 #define VAR_HIDDEN_IN_SHOW_ALL 0x0004 /* for variables hidden in show 90 * all */ 91 #define VAR_NO_RESET_ALL 0x0008 /* for variables not to be reset 92 * with reset all */ 93 #define ARRAY_VAR_ALLOW_NO_INDEX 0x0010 /* for array type vars that also 94 * allows variable with same name 95 * with out index */ 96 #define DEFAULT_FOR_NO_VALUE_ARRAY_VAR 0x0020 97 98 /* From PG's src/include/utils/guc.h */ 99 #define GUC_UNIT_KB 0x1000 /* value is in kilobytes */ 100 #define GUC_UNIT_BLOCKS 0x2000 /* value is in blocks */ 101 #define GUC_UNIT_XBLOCKS 0x3000 /* value is in xlog blocks */ 102 #define GUC_UNIT_MB 0x4000 /* value is in megabytes */ 103 #define GUC_UNIT_BYTE 0x8000 /* value is in bytes */ 104 #define GUC_UNIT_MEMORY 0xF000 /* mask for size-related units */ 105 106 #define GUC_UNIT_MS 0x10000 /* value is in milliseconds */ 107 #define GUC_UNIT_S 0x20000 /* value is in seconds */ 108 #define GUC_UNIT_MIN 0x30000 /* value is in minutes */ 109 #define GUC_UNIT_TIME 0xF0000 /* mask for time-related units */ 110 #define GUC_UNIT (GUC_UNIT_MEMORY | GUC_UNIT_TIME) 111 112 /* 113 * Signatures for per-variable check/assign/show functions 114 */ 115 116 typedef const char *(*VarShowHook) (void); 117 typedef const char *(*IndexedVarShowHook) (int index); 118 typedef bool (*IndexedVarEmptySlotCheck) (int index); 119 120 typedef bool (*ConfigBoolAssignFunc) (ConfigContext scontext, bool newval, int elevel); 121 typedef bool (*ConfigEnumAssignFunc) (ConfigContext scontext, int newval, int elevel); 122 123 typedef bool (*ConfigStringListAssignFunc) (ConfigContext scontext, char *newval, int index); 124 125 typedef bool (*ConfigInt64AssignFunc) (ConfigContext scontext, int64 newval, int elevel); 126 127 typedef bool (*ConfigStringAssignFunc) (ConfigContext scontext, char *newval, int elevel); 128 typedef bool (*ConfigStringArrayAssignFunc) (ConfigContext scontext, char *newval, int index, int elevel); 129 130 typedef bool (*ConfigIntAssignFunc) (ConfigContext scontext, int newval, int elevel); 131 typedef bool (*ConfigIntArrayAssignFunc) (ConfigContext scontext, int newval, int index, int elevel); 132 133 typedef bool (*ConfigDoubleAssignFunc) (ConfigContext scontext, double newval, int elevel); 134 typedef bool (*ConfigDoubleArrayAssignFunc) (ConfigContext scontext, double newval, int index, int elevel); 135 136 typedef bool (*ConfigStringProcessingFunc) (char *newval, int elevel); 137 typedef bool (*ConfigEnumProcessingFunc) (int newval, int elevel); 138 139 140 struct config_generic 141 { 142 /* constant fields, must be set correctly in initial value: */ 143 const char *name; /* name of variable - MUST BE FIRST */ 144 ConfigContext context; /* context required to set the variable */ 145 config_group group; /* to help organize variables by function */ 146 const char *description; /* short desc. of this variable's purpose */ 147 config_type vartype; /* type of variable (set only at startup) */ 148 bool dynamic_array_var; /* true if the variable name contains 149 * index postfix */ 150 int flags; /* flags */ 151 int max_elements; /* number of maximum elements, only valid for 152 * array type configs */ 153 int status; /* status bits, see below */ 154 int sourceline; /* line in source file */ 155 156 157 GucSource *sources; /* source of the current actual value, For 158 * array type config elements it contains the 159 * corresponding source of each individual 160 * element */ 161 GucSource *reset_sources; /* source of the reset value, For array type 162 * config elements it contains the 163 * corresponding source of each individual 164 * element */ 165 ConfigContext *scontexts; /* context that set the current value, For 166 * array type config elements it contains the 167 * corresponding context of each individual 168 * element */ 169 170 }; 171 172 173 /* GUC records for specific variable types */ 174 175 struct config_bool 176 { 177 struct config_generic gen; 178 /* constant fields, must be set correctly in initial value: */ 179 bool *variable; 180 bool boot_val; 181 ConfigBoolAssignFunc assign_func; 182 ConfigBoolAssignFunc check_func; 183 VarShowHook show_hook; 184 bool reset_val; 185 }; 186 187 struct config_int 188 { 189 struct config_generic gen; 190 /* constant fields, must be set correctly in initial value: */ 191 int *variable; 192 int boot_val; 193 int min; 194 int max; 195 ConfigIntAssignFunc assign_func; 196 ConfigIntAssignFunc check_func; 197 VarShowHook show_hook; 198 int reset_val; 199 }; 200 201 struct config_int_array 202 { 203 struct config_generic gen; 204 /* constant fields, must be set correctly in initial value: */ 205 int **variable; 206 int boot_val; 207 int min; 208 int max; 209 210 struct config_int config_no_index; /* int type record if the array also 211 * includes master value (value 212 * without index postfix ) */ 213 214 ConfigIntArrayAssignFunc assign_func; 215 ConfigIntArrayAssignFunc check_func; 216 IndexedVarShowHook show_hook; 217 IndexedVarEmptySlotCheck empty_slot_check_func; 218 int *reset_vals; /* Array of reset values */ 219 }; 220 221 struct config_double 222 { 223 struct config_generic gen; 224 /* constant fields, must be set correctly in initial value: */ 225 double *variable; 226 double boot_val; 227 double min; 228 double max; 229 ConfigDoubleAssignFunc assign_func; 230 ConfigDoubleAssignFunc check_func; 231 VarShowHook show_hook; 232 double reset_val; 233 }; 234 235 struct config_double_array 236 { 237 struct config_generic gen; 238 /* constant fields, must be set correctly in initial value: */ 239 double **variable; 240 double boot_val; 241 double min; 242 double max; 243 244 struct config_double config_no_index; /* record if the array also 245 * includes master value (value 246 * without index postfix ) */ 247 ConfigDoubleArrayAssignFunc assign_func; 248 ConfigDoubleArrayAssignFunc check_func; 249 IndexedVarShowHook show_hook; 250 IndexedVarEmptySlotCheck empty_slot_check_func; 251 double *reset_vals; 252 }; 253 254 struct config_long 255 { 256 struct config_generic gen; 257 /* constant fields, must be set correctly in initial value: */ 258 int64 *variable; 259 int64 boot_val; 260 int64 min; 261 int64 max; 262 ConfigInt64AssignFunc assign_func; 263 ConfigInt64AssignFunc check_func; 264 VarShowHook show_hook; 265 int64 reset_val; 266 }; 267 268 struct config_string 269 { 270 struct config_generic gen; 271 /* constant fields, must be set correctly in initial value: */ 272 char **variable; 273 const char *boot_val; 274 ConfigStringAssignFunc assign_func; 275 ConfigStringAssignFunc check_func; 276 ConfigStringProcessingFunc process_func; 277 VarShowHook show_hook; 278 char *reset_val; 279 }; 280 281 struct config_string_array 282 { 283 struct config_generic gen; 284 /* constant fields, must be set correctly in initial value: */ 285 char ***variable; 286 const char *boot_val; 287 288 struct config_string config_no_index; /* record if the array also 289 * includes master value (value 290 * without index postfix ) */ 291 ConfigStringArrayAssignFunc assign_func; 292 ConfigStringArrayAssignFunc check_func; 293 IndexedVarShowHook show_hook; 294 IndexedVarEmptySlotCheck empty_slot_check_func; 295 char **reset_vals; 296 }; 297 298 struct config_string_list 299 { 300 struct config_generic gen; 301 /* constant fields, must be set correctly in initial value: */ 302 char ***variable; 303 int *list_elements_count; 304 const char *boot_val; 305 const char *separator; 306 bool compute_regex; 307 ConfigStringListAssignFunc assign_func; 308 ConfigStringListAssignFunc check_func; 309 VarShowHook show_hook; 310 char *reset_val; 311 char *current_val; 312 }; 313 314 struct config_enum 315 { 316 struct config_generic gen; 317 /* constant fields, must be set correctly in initial value: */ 318 int *variable; 319 int boot_val; 320 const struct config_enum_entry *options; 321 ConfigEnumAssignFunc assign_func; 322 ConfigEnumAssignFunc check_func; 323 ConfigEnumProcessingFunc process_func; 324 VarShowHook show_hook; 325 int reset_val; 326 }; 327 328 struct config_grouped_array_var 329 { 330 struct config_generic gen; 331 int var_count; 332 struct config_generic **var_list; 333 }; 334 335 336 extern void InitializeConfigOptions(void); 337 extern bool set_one_config_option(const char *name, const char *value, 338 ConfigContext context, GucSource source, int elevel); 339 340 extern bool set_config_options(ConfigVariable *head_p, 341 ConfigContext context, GucSource source, int elevel); 342 343 344 #ifndef POOL_PRIVATE 345 extern bool report_config_variable(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, const char *var_name); 346 extern bool report_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); 347 extern bool set_config_option_for_session(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, const char *name, const char *value); 348 bool reset_all_variables(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); 349 #endif 350 351 #endif /* POOL_CONFIG_VARIABLES_H */ 352