1 /*--------------------------------------------------------------------
4 * Support for grand unified configuration scheme, including SET
5 * command, configuration file, and command line options.
7 * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.39 2001/06/18 16:14:43 momjian Exp $
9 * Copyright 2000 by PostgreSQL Global Development Group
10 * Written by Peter Eisentraut <peter_e@gmx.net>.
11 *--------------------------------------------------------------------
21 #include "utils/guc.h"
23 #include "access/xlog.h"
24 #include "commands/async.h"
26 #include "libpq/auth.h"
27 #include "libpq/pqcomm.h"
28 #include "miscadmin.h"
29 #include "optimizer/cost.h"
30 #include "optimizer/geqo.h"
31 #include "optimizer/paths.h"
32 #include "optimizer/planmain.h"
33 #include "parser/parse_expr.h"
34 #include "storage/proc.h"
35 #include "tcop/tcopprot.h"
36 #include "utils/datetime.h"
39 /* XXX these should be in other modules' header files */
40 extern bool Log_connections;
41 extern int CheckPointTimeout;
42 extern int CommitDelay;
43 extern int CommitSiblings;
47 extern char *Syslog_facility;
48 extern char *Syslog_ident;
49 static bool check_facility(const char *facility);
55 #ifdef USE_ASSERT_CHECKING
56 bool assert_enabled = true;
58 bool Debug_print_query = false;
59 bool Debug_print_plan = false;
60 bool Debug_print_parse = false;
61 bool Debug_print_rewritten = false;
62 bool Debug_pretty_print = false;
64 bool Show_parser_stats = false;
65 bool Show_planner_stats = false;
66 bool Show_executor_stats = false;
67 bool Show_query_stats = false; /* this is sort of all three above
69 bool Show_btree_build_stats = false;
71 bool SQL_inheritance = true;
73 bool Australian_timezones = false;
76 #define PG_KRB_SRVTAB ""
81 * Declarations for GUC tables
107 /* No need for parse_hook ... presumably both values are legal */
108 void (*assign_hook) (bool newval);
120 bool (*parse_hook) (int proposed);
121 void (*assign_hook) (int newval);
133 bool (*parse_hook) (double proposed);
134 void (*assign_hook) (double newval);
138 * String value options are allocated with strdup, not with the
139 * pstrdup/palloc mechanisms. That is because configuration settings
140 * are already in place before the memory subsystem is up. It would
141 * perhaps be an idea to change that sometime.
148 const char *boot_default_val;
149 bool (*parse_hook) (const char *proposed);
150 void (*assign_hook) (const char *newval);
158 * 1. Declare a global variable of type bool, int, double, or char*
159 * and make use of it.
161 * 2. Decide at what times it's safe to set the option. See guc.h for
164 * 3. Decide on a name, a default value, upper and lower bounds (if
167 * 4. Add a record below.
169 * 5. Add it to postgresql.conf.sample
171 * 6. Don't forget to document that option.
173 * WHEN MAKING MODIFICATIONS, remember to update postgresql.conf.sample
178 /******** option names follow ********/
180 static struct config_bool
181 ConfigureNamesBool[] =
183 {"enable_seqscan", PGC_USERSET, &enable_seqscan, true, NULL},
184 {"enable_indexscan", PGC_USERSET, &enable_indexscan, true, NULL},
185 {"enable_tidscan", PGC_USERSET, &enable_tidscan, true, NULL},
186 {"enable_sort", PGC_USERSET, &enable_sort, true, NULL},
187 {"enable_nestloop", PGC_USERSET, &enable_nestloop, true, NULL},
188 {"enable_mergejoin", PGC_USERSET, &enable_mergejoin, true, NULL},
189 {"enable_hashjoin", PGC_USERSET, &enable_hashjoin, true, NULL},
191 {"ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false, NULL},
192 {"geqo", PGC_USERSET, &enable_geqo, true, NULL},
194 {"tcpip_socket", PGC_POSTMASTER, &NetServer, false, NULL},
195 {"ssl", PGC_POSTMASTER, &EnableSSL, false, NULL},
196 {"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
197 {"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},
199 {"log_connections", PGC_SIGHUP, &Log_connections, false, NULL},
200 {"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
201 {"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},
203 #ifdef USE_ASSERT_CHECKING
204 {"debug_assertions", PGC_USERSET, &assert_enabled, true, NULL},
207 {"debug_print_query", PGC_USERSET, &Debug_print_query, false, NULL},
208 {"debug_print_parse", PGC_USERSET, &Debug_print_parse, false, NULL},
209 {"debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false, NULL},
210 {"debug_print_plan", PGC_USERSET, &Debug_print_plan, false, NULL},
211 {"debug_pretty_print", PGC_USERSET, &Debug_pretty_print, false, NULL},
213 {"show_parser_stats", PGC_USERSET, &Show_parser_stats, false, NULL},
214 {"show_planner_stats", PGC_USERSET, &Show_planner_stats, false, NULL},
215 {"show_executor_stats", PGC_USERSET, &Show_executor_stats, false, NULL},
216 {"show_query_stats", PGC_USERSET, &Show_query_stats, false, NULL},
217 #ifdef BTREE_BUILD_STATS
218 {"show_btree_build_stats", PGC_SUSET, &Show_btree_build_stats, false, NULL},
221 {"trace_notify", PGC_USERSET, &Trace_notify, false, NULL},
224 {"trace_locks", PGC_SUSET, &Trace_locks, false, NULL},
225 {"trace_userlocks", PGC_SUSET, &Trace_userlocks, false, NULL},
226 {"trace_spinlocks", PGC_SUSET, &Trace_spinlocks, false, NULL},
227 {"debug_deadlocks", PGC_SUSET, &Debug_deadlocks, false, NULL},
230 {"hostname_lookup", PGC_SIGHUP, &HostnameLookup, false, NULL},
231 {"show_source_port", PGC_SIGHUP, &ShowPortNumber, false, NULL},
233 {"sql_inheritance", PGC_USERSET, &SQL_inheritance, true, NULL},
235 {"australian_timezones", PGC_USERSET, &Australian_timezones,
236 false, ClearDateCache},
238 {"fixbtree", PGC_POSTMASTER, &FixBTree, true, NULL},
240 {NULL, 0, NULL, false, NULL}
244 static struct config_int
245 ConfigureNamesInt[] =
247 {"geqo_threshold", PGC_USERSET, &geqo_rels,
248 DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL},
249 {"geqo_pool_size", PGC_USERSET, &Geqo_pool_size,
250 DEFAULT_GEQO_POOL_SIZE, 0, MAX_GEQO_POOL_SIZE, NULL, NULL},
251 {"geqo_effort", PGC_USERSET, &Geqo_effort,
252 1, 1, INT_MAX, NULL, NULL},
253 {"geqo_generations", PGC_USERSET, &Geqo_generations,
254 0, 0, INT_MAX, NULL, NULL},
255 {"geqo_random_seed", PGC_USERSET, &Geqo_random_seed,
256 -1, INT_MIN, INT_MAX, NULL, NULL},
258 {"deadlock_timeout", PGC_POSTMASTER, &DeadlockTimeout,
259 1000, 0, INT_MAX, NULL, NULL},
262 {"syslog", PGC_SIGHUP, &Use_syslog,
263 0, 0, 2, NULL, NULL},
267 * Note: There is some postprocessing done in PostmasterMain() to make
268 * sure the buffers are at least twice the number of backends, so the
269 * constraints here are partially unused.
271 {"max_connections", PGC_POSTMASTER, &MaxBackends,
272 DEF_MAXBACKENDS, 1, MAXBACKENDS, NULL, NULL},
273 {"shared_buffers", PGC_POSTMASTER, &NBuffers,
274 DEF_NBUFFERS, 16, INT_MAX, NULL, NULL},
275 {"port", PGC_POSTMASTER, &PostPortNumber,
276 DEF_PGPORT, 1, 65535, NULL, NULL},
278 {"sort_mem", PGC_USERSET, &SortMem,
279 512, 1, INT_MAX, NULL, NULL},
281 {"debug_level", PGC_USERSET, &DebugLvl,
282 0, 0, 16, NULL, NULL},
285 {"trace_lock_oidmin", PGC_SUSET, &Trace_lock_oidmin,
286 BootstrapObjectIdData, 1, INT_MAX, NULL, NULL},
287 {"trace_lock_table", PGC_SUSET, &Trace_lock_table,
288 0, 0, INT_MAX, NULL, NULL},
290 {"max_expr_depth", PGC_USERSET, &max_expr_depth,
291 DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL},
293 {"unix_socket_permissions", PGC_POSTMASTER, &Unix_socket_permissions,
294 0777, 0000, 0777, NULL, NULL},
296 {"checkpoint_segments", PGC_SIGHUP, &CheckPointSegments,
297 3, 1, INT_MAX, NULL, NULL},
299 {"checkpoint_timeout", PGC_SIGHUP, &CheckPointTimeout,
300 300, 30, 3600, NULL, NULL},
302 {"wal_buffers", PGC_POSTMASTER, &XLOGbuffers,
303 8, 4, INT_MAX, NULL, NULL},
305 {"wal_files", PGC_SIGHUP, &XLOGfiles,
306 0, 0, 64, NULL, NULL},
308 {"wal_debug", PGC_SUSET, &XLOG_DEBUG,
309 0, 0, 16, NULL, NULL},
311 {"commit_delay", PGC_USERSET, &CommitDelay,
312 0, 0, 100000, NULL, NULL},
314 {"commit_siblings", PGC_USERSET, &CommitSiblings,
315 5, 1, 1000, NULL, NULL},
317 {NULL, 0, NULL, 0, 0, 0, NULL, NULL}
321 static struct config_real
322 ConfigureNamesReal[] =
324 {"effective_cache_size", PGC_USERSET, &effective_cache_size,
325 DEFAULT_EFFECTIVE_CACHE_SIZE, 0, DBL_MAX, NULL, NULL},
326 {"random_page_cost", PGC_USERSET, &random_page_cost,
327 DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL},
328 {"cpu_tuple_cost", PGC_USERSET, &cpu_tuple_cost,
329 DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL},
330 {"cpu_index_tuple_cost", PGC_USERSET, &cpu_index_tuple_cost,
331 DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL},
332 {"cpu_operator_cost", PGC_USERSET, &cpu_operator_cost,
333 DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL},
335 {"geqo_selection_bias", PGC_USERSET, &Geqo_selection_bias,
336 DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS,
337 MAX_GEQO_SELECTION_BIAS, NULL, NULL},
339 {NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, NULL}
343 static struct config_string
344 ConfigureNamesString[] =
346 {"dynamic_library_path", PGC_SUSET, &Dynamic_library_path,
347 "$libdir", NULL, NULL},
349 {"krb_server_keyfile", PGC_POSTMASTER, &pg_krb_server_keyfile,
350 PG_KRB_SRVTAB, NULL, NULL},
353 {"syslog_facility", PGC_POSTMASTER, &Syslog_facility,
354 "LOCAL0", check_facility, NULL},
355 {"syslog_ident", PGC_POSTMASTER, &Syslog_ident,
356 "postgres", NULL, NULL},
359 {"unix_socket_group", PGC_POSTMASTER, &Unix_socket_group,
362 {"unix_socket_directory", PGC_POSTMASTER, &UnixSocketDir,
365 {"virtual_host", PGC_POSTMASTER, &VirtualHost,
368 {"wal_sync_method", PGC_SIGHUP, &XLOG_sync_method,
369 XLOG_sync_method_default, check_xlog_sync_method,
370 assign_xlog_sync_method},
372 {NULL, 0, NULL, NULL, NULL, NULL}
375 /******** end of options list ********/
380 * Look up option NAME. If it exists, return it's data type, else
381 * PGC_NONE (zero). If record is not NULL, store the description of
384 static enum config_type
385 find_option(const char *name, struct config_generic ** record)
391 for (i = 0; ConfigureNamesBool[i].name; i++)
392 if (strcasecmp(ConfigureNamesBool[i].name, name) == 0)
395 *record = (struct config_generic *) & ConfigureNamesBool[i];
399 for (i = 0; ConfigureNamesInt[i].name; i++)
400 if (strcasecmp(ConfigureNamesInt[i].name, name) == 0)
403 *record = (struct config_generic *) & ConfigureNamesInt[i];
407 for (i = 0; ConfigureNamesReal[i].name; i++)
408 if (strcasecmp(ConfigureNamesReal[i].name, name) == 0)
411 *record = (struct config_generic *) & ConfigureNamesReal[i];
415 for (i = 0; ConfigureNamesString[i].name; i++)
416 if (strcasecmp(ConfigureNamesString[i].name, name) == 0)
419 *record = (struct config_generic *) & ConfigureNamesString[i];
429 * Reset all options to their specified default values. Must be called
430 * with isStartup = true at program startup. May be called later with
431 * isStartup = false to reset all resettable options.
434 ResetAllOptions(bool isStartup)
438 for (i = 0; ConfigureNamesBool[i].name; i++)
440 struct config_bool *conf = &ConfigureNamesBool[i];
443 conf->context == PGC_SUSET || conf->context == PGC_USERSET)
445 if (conf->assign_hook)
446 (conf->assign_hook) (conf->default_val);
447 *conf->variable = conf->default_val;
451 for (i = 0; ConfigureNamesInt[i].name; i++)
453 struct config_int *conf = &ConfigureNamesInt[i];
456 conf->context == PGC_SUSET || conf->context == PGC_USERSET)
458 if (conf->assign_hook)
459 (conf->assign_hook) (conf->default_val);
460 *conf->variable = conf->default_val;
464 for (i = 0; ConfigureNamesReal[i].name; i++)
466 struct config_real *conf = &ConfigureNamesReal[i];
469 conf->context == PGC_SUSET || conf->context == PGC_USERSET)
471 if (conf->assign_hook)
472 (conf->assign_hook) (conf->default_val);
473 *conf->variable = conf->default_val;
477 for (i = 0; ConfigureNamesString[i].name; i++)
479 struct config_string *conf = &ConfigureNamesString[i];
482 conf->context == PGC_SUSET || conf->context == PGC_USERSET)
486 if (conf->default_val == NULL &&
487 conf->boot_default_val)
489 str = strdup(conf->boot_default_val);
491 elog(ERROR, "out of memory");
492 conf->default_val = str;
494 if (conf->default_val)
496 str = strdup(conf->default_val);
498 elog(ERROR, "out of memory");
500 if (conf->assign_hook)
501 (conf->assign_hook) (str);
503 free(*conf->variable);
504 *conf->variable = str;
512 * Try to interpret value as boolean value. Valid values are: true,
513 * false, yes, no, on, off, 1, 0. If the string parses okay, return
514 * true, else false. If result is not NULL, return the parsing result
518 parse_bool(const char *value, bool *result)
520 size_t len = strlen(value);
522 if (strncasecmp(value, "true", len) == 0)
527 else if (strncasecmp(value, "false", len) == 0)
533 else if (strncasecmp(value, "yes", len) == 0)
538 else if (strncasecmp(value, "no", len) == 0)
544 else if (strcasecmp(value, "on") == 0)
549 else if (strcasecmp(value, "off") == 0)
555 else if (strcasecmp(value, "1") == 0)
560 else if (strcasecmp(value, "0") == 0)
574 * Try to parse value as an integer. The accepted formats are the
575 * usual decimal, octal, or hexadecimal formats. If the string parses
576 * okay, return true, else false. If result is not NULL, return the
580 parse_int(const char *value, int *result)
586 val = strtol(value, &endptr, 0);
587 if (endptr == value || *endptr != '\0' || errno == ERANGE
588 #ifdef HAVE_LONG_INT_64
589 /* if long > 32 bits, check for overflow of int4 */
590 || val != (long) ((int32) val)
602 * Try to parse value as a floating point constant in the usual
603 * format. If the value parsed okay return true, else false. If
604 * result is not NULL, return the semantic value there.
607 parse_real(const char *value, double *result)
613 val = strtod(value, &endptr);
614 if (endptr == value || *endptr != '\0' || errno == ERANGE)
624 * Sets option `name' to given value. The value should be a string
625 * which is going to be parsed and converted to the appropriate data
626 * type. Parameter context should indicate in which context this
627 * function is being called so it can apply the access restrictions
630 * If value is NULL, set the option to its default value. If the
631 * parameter DoIt is false then don't really set the option but do all
632 * the checks to see if it would work.
634 * If there is an error (non-existing option, invalid value) then an
635 * elog(ERROR) is thrown *unless* this is called as part of the
636 * configuration file re-read in the SIGHUP handler, in which case we
637 * simply write the error message via elog(DEBUG) and return false. In
638 * all other cases the function returns true. This is working around
639 * the deficiencies in the elog mechanism, so don't blame me.
641 * See also SetConfigOption for an external interface.
644 set_config_option(const char *name, const char *value,
645 GucContext context, bool DoIt, bool makeDefault)
647 struct config_generic *record;
648 enum config_type type;
651 elevel = (context == PGC_SIGHUP) ? DEBUG : ERROR;
653 type = find_option(name, &record);
654 if (type == PGC_NONE)
656 elog(elevel, "'%s' is not a valid option name", name);
661 * Check if the option can be set at this time. See guc.h for the
662 * precise rules. Note that we don't want to throw errors if we're in
663 * the SIGHUP context. In that case we just ignore the attempt.
665 if (record->context == PGC_POSTMASTER && context != PGC_POSTMASTER)
667 if (context != PGC_SIGHUP)
668 elog(ERROR, "'%s' cannot be changed after server start", name);
672 else if (record->context == PGC_SIGHUP && context != PGC_SIGHUP &&
673 context != PGC_POSTMASTER)
675 elog(ERROR, "'%s' cannot be changed now", name);
678 * Hmm, the idea of the SIGHUP context is "ought to be global, but
679 * can be changed after postmaster start". But there's nothing
680 * that prevents a crafty administrator from sending SIGHUP
681 * signals to individual backends only.
684 else if (record->context == PGC_BACKEND && context != PGC_BACKEND
685 && context != PGC_POSTMASTER)
687 if (context != PGC_SIGHUP)
688 elog(ERROR, "'%s' cannot be set after connection start", name);
692 else if (record->context == PGC_SUSET &&
693 (context == PGC_USERSET || context == PGC_BACKEND))
694 elog(ERROR, "permission denied");
698 * Evaluate value and set variable
704 struct config_bool *conf = (struct config_bool *) record;
710 if (!parse_bool(value, &boolval))
712 elog(elevel, "option '%s' requires a boolean value", name);
715 /* no parse_hook needed for booleans */
718 if (conf->assign_hook)
719 (conf->assign_hook) (boolval);
720 *conf->variable = boolval;
722 conf->default_val = boolval;
727 if (conf->assign_hook)
728 (conf->assign_hook) (conf->default_val);
729 *conf->variable = conf->default_val;
736 struct config_int *conf = (struct config_int *) record;
742 if (!parse_int(value, &intval))
744 elog(elevel, "option '%s' expects an integer value", name);
747 if (intval < conf->min || intval > conf->max)
749 elog(elevel, "option '%s' value %d is outside"
750 " of permissible range [%d .. %d]",
751 name, intval, conf->min, conf->max);
754 if (conf->parse_hook && !(conf->parse_hook) (intval))
756 elog(elevel, "invalid value for option '%s': %d",
762 if (conf->assign_hook)
763 (conf->assign_hook) (intval);
764 *conf->variable = intval;
766 conf->default_val = intval;
771 if (conf->assign_hook)
772 (conf->assign_hook) (conf->default_val);
773 *conf->variable = conf->default_val;
780 struct config_real *conf = (struct config_real *) record;
786 if (!parse_real(value, &dval))
788 elog(elevel, "option '%s' expects a real number", name);
791 if (dval < conf->min || dval > conf->max)
793 elog(elevel, "option '%s' value %g is outside"
794 " of permissible range [%g .. %g]",
795 name, dval, conf->min, conf->max);
798 if (conf->parse_hook && !(conf->parse_hook) (dval))
800 elog(elevel, "invalid value for option '%s': %g",
806 if (conf->assign_hook)
807 (conf->assign_hook) (dval);
808 *conf->variable = dval;
810 conf->default_val = dval;
815 if (conf->assign_hook)
816 (conf->assign_hook) (conf->default_val);
817 *conf->variable = conf->default_val;
824 struct config_string *conf = (struct config_string *) record;
828 if (conf->parse_hook && !(conf->parse_hook) (value))
830 elog(elevel, "invalid value for option '%s': '%s'",
841 elog(elevel, "out of memory");
844 if (conf->assign_hook)
845 (conf->assign_hook) (str);
847 free(*conf->variable);
848 *conf->variable = str;
853 elog(elevel, "out of memory");
856 if (conf->default_val)
857 free(conf->default_val);
858 conf->default_val = str;
866 if (!conf->default_val && conf->boot_default_val)
868 str = strdup(conf->boot_default_val);
871 elog(elevel, "out of memory");
874 conf->default_val = str;
876 str = strdup(conf->default_val);
879 elog(elevel, "out of memory");
882 if (conf->assign_hook)
883 (conf->assign_hook) (str);
885 free(*conf->variable);
886 *conf->variable = str;
899 * Set a config option to the given value. See also set_config_option,
900 * this is just the wrapper to be called from the outside.
903 SetConfigOption(const char *name, const char *value,
904 GucContext context, bool makeDefault)
906 (void) set_config_option(name, value, context, true, makeDefault);
912 * This is more or less the SHOW command. It returns a string with the
913 * value of the option `name'. If the option doesn't exist, throw an
914 * elog and don't return.
916 * The string is *not* allocated for modification and is really only
917 * valid until the next call to configuration related functions.
920 GetConfigOption(const char *name)
922 struct config_generic *record;
923 static char buffer[256];
924 enum config_type opttype;
926 opttype = find_option(name, &record);
927 if (opttype == PGC_NONE)
928 elog(ERROR, "Option '%s' is not recognized", name);
933 return *((struct config_bool *) record)->variable ? "on" : "off";
936 snprintf(buffer, sizeof(buffer), "%d",
937 *((struct config_int *) record)->variable);
941 snprintf(buffer, sizeof(buffer), "%g",
942 *((struct config_real *) record)->variable);
946 return *((struct config_string *) record)->variable;
955 _ShowOption(enum config_type opttype, struct config_generic *record)
963 val = *((struct config_bool *) record)->variable ? "on" : "off";
967 snprintf(buffer, sizeof(buffer), "%d",
968 *((struct config_int *) record)->variable);
973 snprintf(buffer, sizeof(buffer), "%g",
974 *((struct config_real *) record)->variable);
979 val = strlen(*((struct config_string *) record)->variable) != 0 ?
980 *((struct config_string *) record)->variable : "unset";
986 elog(NOTICE, "%s is %s", record->name, val);
990 ShowAllGUCConfig(void)
994 for (i = 0; ConfigureNamesBool[i].name; i++)
995 _ShowOption(PGC_BOOL, (struct config_generic *)&ConfigureNamesBool[i]);
997 for (i = 0; ConfigureNamesInt[i].name; i++)
998 _ShowOption(PGC_INT, (struct config_generic *)&ConfigureNamesInt[i]);
1000 for (i = 0; ConfigureNamesReal[i].name; i++)
1001 _ShowOption(PGC_REAL, (struct config_generic *)&ConfigureNamesReal[i]);
1003 for (i = 0; ConfigureNamesString[i].name; i++)
1004 _ShowOption(PGC_STRING, (struct config_generic *)&ConfigureNamesString[i]);
1012 * A little "long argument" simulation, although not quite GNU
1013 * compliant. Takes a string of the form "some-option=some value" and
1014 * returns name = "some_option" and value = "some value" in malloc'ed
1015 * storage. Note that '-' is converted to '_' in the option name. If
1016 * there is no '=' in the input string then value will be NULL.
1019 ParseLongOption(const char *string, char **name, char **value)
1028 equal_pos = strcspn(string, "=");
1030 if (string[equal_pos] == '=')
1032 *name = malloc(equal_pos + 1);
1034 elog(FATAL, "out of memory");
1035 strncpy(*name, string, equal_pos);
1036 (*name)[equal_pos] = '\0';
1038 *value = strdup(&string[equal_pos + 1]);
1040 elog(FATAL, "out of memory");
1044 /* no equal sign in string */
1045 *name = strdup(string);
1047 elog(FATAL, "out of memory");
1051 for (cp = *name; *cp; cp++)
1058 #ifdef ENABLE_SYSLOG
1061 check_facility(const char *facility)
1063 if (strcasecmp(facility, "LOCAL0") == 0)
1065 if (strcasecmp(facility, "LOCAL1") == 0)
1067 if (strcasecmp(facility, "LOCAL2") == 0)
1069 if (strcasecmp(facility, "LOCAL3") == 0)
1071 if (strcasecmp(facility, "LOCAL4") == 0)
1073 if (strcasecmp(facility, "LOCAL5") == 0)
1075 if (strcasecmp(facility, "LOCAL6") == 0)
1077 if (strcasecmp(facility, "LOCAL7") == 0)