summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuhammad Usama2014-04-30 10:41:24 +0000
committerMuhammad Usama2014-04-30 10:41:24 +0000
commit1977ce5a15ac13a803343ebe5eddbed56c609075 (patch)
tree65ecee378be95f7ca70c61ec99a930f5ced84992
parentf97125fea7b4491b569c6c9c702299b896711d26 (diff)
parentef89a07ac13bccd634967cac9c46cbb378825349 (diff)
Merge branch 'EXCEPTION_MGR' of ssh://git.postgresql.org/pgpool2 into EXCEPTION_MGREXCEPTION_MGR
Conflicts: src/auth/pool_auth.c src/config/pool_config.c src/context/pool_query_context.c src/libs/pcp/Makefile.am src/libs/pcp/Makefile.in src/libs/pcp/pcp.c src/main/main.c src/main/pgpool_main.c src/protocol/child.c src/protocol/pool_proto_modules.c src/tools/pgmd5/Makefile.am
-rw-r--r--src/auth/pool_auth.c5
-rw-r--r--src/config/pool_config.c5066
-rw-r--r--src/context/pool_query_context.c2
-rw-r--r--src/libs/pcp/Makefile.am3
-rw-r--r--src/libs/pcp/Makefile.in14
-rw-r--r--src/libs/pcp/pcp.c1
-rw-r--r--src/main/main.c6
-rw-r--r--src/main/pgpool_main.c24
-rw-r--r--src/protocol/child.c17
-rw-r--r--src/protocol/pool_proto_modules.c7
-rw-r--r--src/tools/pgmd5/Makefile.am1
11 files changed, 5106 insertions, 40 deletions
diff --git a/src/auth/pool_auth.c b/src/auth/pool_auth.c
index e56041385..9188491f1 100644
--- a/src/auth/pool_auth.c
+++ b/src/auth/pool_auth.c
@@ -410,10 +410,11 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
}
if (pid == -1)
+ {
ereport(ERROR,
(errmsg("authentication failed"),
- errdetail("all backends are down")));
-
+ errdetail("pool_do_auth: all backends are down")));
+ }
if(pool_send_backend_key_data(frontend, pid, key, protoMajor))
ereport(ERROR,
(errmsg("authentication failed"),
diff --git a/src/config/pool_config.c b/src/config/pool_config.c
new file mode 100644
index 000000000..fb22b9b0a
--- /dev/null
+++ b/src/config/pool_config.c
@@ -0,0 +1,5066 @@
+
+#line 3 "config/pool_config.c"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+#ifdef __cplusplus
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
+
+#define YY_USE_CONST
+
+#endif /* defined (__STDC__) */
+#endif /* ! __cplusplus */
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN (yy_start) = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START (((yy_start) - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart(yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+extern int yyleng;
+
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ #define YY_LESS_LINENO(n)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
+ YY_RESTORE_YY_MORE_OFFSET \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, (yytext_ptr) )
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 0; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart (FILE *input_file );
+void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
+void yy_delete_buffer (YY_BUFFER_STATE b );
+void yy_flush_buffer (YY_BUFFER_STATE b );
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
+void yypop_buffer_state (void );
+
+static void yyensure_buffer_stack (void );
+static void yy_load_buffer_state (void );
+static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
+
+#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
+
+YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
+
+void *yyalloc (yy_size_t );
+void *yyrealloc (void *,yy_size_t );
+void yyfree (void * );
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define yywrap(n) 1
+#define YY_SKIP_YYWRAP
+
+typedef unsigned char YY_CHAR;
+
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+
+typedef int yy_state_type;
+
+extern int yylineno;
+
+int yylineno = 1;
+
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+static void yy_fatal_error (yyconst char msg[] );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ (yytext_ptr) = yy_bp; \
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
+ *yy_cp = '\0'; \
+ (yy_c_buf_p) = yy_cp;
+
+#define YY_NUM_RULES 11
+#define YY_END_OF_BUFFER 12
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[38] =
+ { 0,
+ 0, 0, 12, 10, 2, 1, 10, 10, 10, 8,
+ 7, 7, 9, 4, 2, 0, 3, 0, 5, 0,
+ 8, 7, 7, 8, 0, 0, 6, 4, 4, 0,
+ 5, 0, 0, 8, 7, 6, 0
+ } ;
+
+static yyconst flex_int32_t yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 1, 4, 1, 1, 1, 5, 1,
+ 1, 1, 6, 1, 7, 8, 9, 10, 11, 11,
+ 11, 11, 11, 11, 11, 11, 11, 9, 1, 1,
+ 12, 1, 1, 1, 13, 13, 13, 13, 14, 13,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 1, 16, 1, 1, 17, 1, 13, 13, 13, 13,
+
+ 14, 13, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 18,
+ 15, 15, 1, 1, 1, 1, 1, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15
+ } ;
+
+static yyconst flex_int32_t yy_meta[19] =
+ { 0,
+ 1, 1, 2, 1, 1, 1, 3, 3, 3, 4,
+ 4, 1, 5, 4, 3, 1, 3, 3
+ } ;
+
+static yyconst flex_int16_t yy_base[45] =
+ { 0,
+ 0, 0, 61, 86, 58, 86, 55, 14, 23, 43,
+ 10, 46, 86, 28, 47, 40, 86, 16, 86, 22,
+ 28, 0, 0, 0, 40, 0, 24, 45, 0, 24,
+ 39, 43, 12, 14, 0, 22, 86, 62, 67, 22,
+ 70, 75, 77, 80
+ } ;
+
+static yyconst flex_int16_t yy_def[45] =
+ { 0,
+ 37, 1, 37, 37, 37, 37, 38, 39, 37, 40,
+ 9, 9, 37, 41, 37, 38, 37, 39, 37, 42,
+ 40, 11, 12, 21, 37, 43, 44, 41, 28, 39,
+ 39, 42, 37, 37, 43, 44, 0, 37, 37, 37,
+ 37, 37, 37, 37
+ } ;
+
+static yyconst flex_int16_t yy_nxt[105] =
+ { 0,
+ 4, 5, 6, 7, 8, 9, 9, 10, 4, 11,
+ 12, 13, 14, 14, 14, 4, 14, 14, 19, 23,
+ 19, 34, 34, 34, 34, 24, 31, 26, 19, 20,
+ 21, 20, 22, 23, 27, 27, 27, 32, 36, 20,
+ 36, 25, 17, 19, 29, 33, 33, 31, 15, 34,
+ 34, 27, 27, 27, 20, 23, 25, 17, 32, 15,
+ 37, 29, 16, 16, 16, 16, 16, 18, 37, 18,
+ 18, 18, 28, 28, 28, 30, 37, 30, 30, 30,
+ 35, 35, 27, 27, 27, 3, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+
+ 37, 37, 37, 37
+ } ;
+
+static yyconst flex_int16_t yy_chk[105] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 8, 11,
+ 18, 33, 33, 34, 34, 40, 20, 11, 30, 8,
+ 9, 18, 9, 9, 14, 14, 14, 20, 36, 30,
+ 27, 21, 16, 31, 14, 25, 25, 32, 15, 25,
+ 25, 28, 28, 28, 31, 12, 10, 7, 32, 5,
+ 3, 28, 38, 38, 38, 38, 38, 39, 0, 39,
+ 39, 39, 41, 41, 41, 42, 0, 42, 42, 42,
+ 43, 43, 44, 44, 44, 37, 37, 37, 37, 37,
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
+
+ 37, 37, 37, 37
+ } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+extern int yy_flex_debug;
+int yy_flex_debug = 0;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "pool_config.l"
+/* -*-pgsql-c-*- */
+/*
+ *
+ * $Header$
+ *
+ * pgpool: a language independent connection pool server for PostgreSQL
+ * written by Tatsuo Ishii
+ *
+ * Copyright (c) 2003-2014 PgPool Global Development Group
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that the above copyright notice appear in all
+ * copies and that both that copyright notice and this permission
+ * notice appear in supporting documentation, and that the name of the
+ * author not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. The author makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * pool_config.l: read configuration file
+ *
+ */
+#line 27 "pool_config.l"
+#include "pool.h"
+#include "pool_config.h"
+#ifndef POOL_PRIVATE
+#include "utils/elog.h"
+#else
+#include "utils/fe_ports.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define CHECK_CONTEXT(mask, context) ((mask) & (context))
+
+#ifdef POOL_PRIVATE
+
+/* we do not have elog api for pg_md5 utility*/
+/* include/utils/elog.h */
+#define ereport(elevel, rest) printf("pool_config: error at %s:%d\n", __FILE__, __LINE__)
+#define ereport(elevel, rest) printf("pool_config: error at %s:%d\n", __FILE__, __LINE__)
+
+#endif
+
+/* to shut off compiler warnings */
+int yylex(void);
+
+POOL_CONFIG *pool_config; /* configuration values */
+POOL_SYSTEMDB_CONNECTION_POOL *system_db_info;
+static unsigned Lineno;
+static char *default_reset_query_list[] = {"ABORT", "DISCARD ALL"};
+static char *default_black_function_list[] = {"nextval", "setval"};
+
+typedef enum {
+ POOL_KEY = 1,
+ POOL_INTEGER,
+ POOL_REAL,
+ POOL_STRING,
+ POOL_UNQUOTED_STRING,
+ POOL_EQUALS,
+ POOL_EOL,
+ POOL_PARSE_ERROR
+} POOL_TOKEN;
+
+static char *extract_string(char *value, POOL_TOKEN token);
+static char **extract_string_tokens(char *str, char *delim, int *n);
+static void clear_host_entry(int slot);
+
+#line 567 "config/pool_config.c"
+
+#define INITIAL 0
+
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy (void );
+
+int yyget_debug (void );
+
+void yyset_debug (int debug_flag );
+
+YY_EXTRA_TYPE yyget_extra (void );
+
+void yyset_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *yyget_in (void );
+
+void yyset_in (FILE * in_str );
+
+FILE *yyget_out (void );
+
+void yyset_out (FILE * out_str );
+
+int yyget_leng (void );
+
+char *yyget_text (void );
+
+int yyget_lineno (void );
+
+void yyset_lineno (int line_number );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap (void );
+#else
+extern int yywrap (void );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char *,yyconst char *,int );
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * );
+#endif
+
+#ifndef YY_NO_INPUT
+
+#ifdef __cplusplus
+static int yyinput (void );
+#else
+static int input (void );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ size_t n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (void);
+
+#define YY_DECL int yylex (void)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 98 "pool_config.l"
+
+
+#line 755 "config/pool_config.c"
+
+ if ( !(yy_init) )
+ {
+ (yy_init) = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
+ }
+
+ yy_load_buffer_state( );
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = (yy_c_buf_p);
+
+ /* Support of yytext. */
+ *yy_cp = (yy_hold_char);
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = (yy_start);
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 38 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_current_state != 37 );
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+
+ YY_DO_BEFORE_ACTION;
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+
+case 1:
+/* rule 1 can match eol */
+YY_RULE_SETUP
+#line 100 "pool_config.l"
+Lineno++; return POOL_EOL;
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 101 "pool_config.l"
+/* eat whitespace */
+ YY_BREAK
+case 3:
+*yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
+(yy_c_buf_p) = yy_cp -= 1;
+YY_DO_BEFORE_ACTION; /* set up yytext again */
+YY_RULE_SETUP
+#line 102 "pool_config.l"
+/* eat comment */
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 104 "pool_config.l"
+return POOL_KEY;
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 105 "pool_config.l"
+return POOL_STRING;
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 106 "pool_config.l"
+return POOL_UNQUOTED_STRING;
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 107 "pool_config.l"
+return POOL_INTEGER;
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 108 "pool_config.l"
+return POOL_REAL;
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 109 "pool_config.l"
+return POOL_EQUALS;
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 111 "pool_config.l"
+return POOL_PARSE_ERROR;
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 113 "pool_config.l"
+ECHO;
+ YY_BREAK
+#line 893 "config/pool_config.c"
+case YY_STATE_EOF(INITIAL):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = (yy_hold_char);
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++(yy_c_buf_p);
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ (yy_did_buffer_switch_on_eof) = 0;
+
+ if ( yywrap( ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
+
+ yy_current_state = yy_get_previous_state( );
+
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+} /* end of yylex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+
+ int yy_c_buf_p_offset =
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ if ( (yy_n_chars) == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart(yyin );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
+
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
+
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (void)
+{
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = (yy_start);
+
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 38 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
+ register int yy_is_jam;
+ register char *yy_cp = (yy_c_buf_p);
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 38 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 37);
+
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (void)
+#else
+ static int input (void)
+#endif
+
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
+
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
+ /* This was really a NUL. */
+ *(yy_c_buf_p) = '\0';
+
+ else
+ { /* need more input */
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
+
+ switch ( yy_get_next_buffer( ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart(yyin );
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap( ) )
+ return EOF;
+
+ if ( ! (yy_did_buffer_switch_on_eof) )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ (yy_c_buf_p) = (yytext_ptr) + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve yytext */
+ (yy_hold_char) = *++(yy_c_buf_p);
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void yyrestart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
+ }
+
+ yy_init_buffer(YY_CURRENT_BUFFER,input_file );
+ yy_load_buffer_state( );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
+ */
+ yyensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ yy_load_buffer_state( );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+static void yy_load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer(b,file );
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ *
+ */
+ void yy_delete_buffer (YY_BUFFER_STATE b )
+{
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yyfree((void *) b->yy_ch_buf );
+
+ yyfree((void *) b );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
+
+{
+ int oerrno = errno;
+
+ yy_flush_buffer(b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void yy_flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ yy_load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ yyensure_buffer_stack();
+
+ /* This block is copied from yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void yypop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void yyensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
+
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer(b );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
+{
+
+ return yy_scan_bytes(yystr,strlen(yystr) );
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = _yybytes_len + 2;
+ buf = (char *) yyalloc(n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer(buf,n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = (yy_hold_char); \
+ (yy_c_buf_p) = yytext + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the current line number.
+ *
+ */
+int yyget_lineno (void)
+{
+
+ return yylineno;
+}
+
+/** Get the input stream.
+ *
+ */
+FILE *yyget_in (void)
+{
+ return yyin;
+}
+
+/** Get the output stream.
+ *
+ */
+FILE *yyget_out (void)
+{
+ return yyout;
+}
+
+/** Get the length of the current token.
+ *
+ */
+int yyget_leng (void)
+{
+ return yyleng;
+}
+
+/** Get the current token.
+ *
+ */
+
+char *yyget_text (void)
+{
+ return yytext;
+}
+
+/** Set the current line number.
+ * @param line_number
+ *
+ */
+void yyset_lineno (int line_number )
+{
+
+ yylineno = line_number;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param in_str A readable stream.
+ *
+ * @see yy_switch_to_buffer
+ */
+void yyset_in (FILE * in_str )
+{
+ yyin = in_str ;
+}
+
+void yyset_out (FILE * out_str )
+{
+ yyout = out_str ;
+}
+
+int yyget_debug (void)
+{
+ return yy_flex_debug;
+}
+
+void yyset_debug (int bdebug )
+{
+ yy_flex_debug = bdebug ;
+}
+
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from yylex_destroy(), so don't allocate here.
+ */
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ yyin = stdin;
+ yyout = stdout;
+#else
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * yylex_init()
+ */
+ return 0;
+}
+
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ yypop_buffer_state();
+ }
+
+ /* Destroy the stack itself. */
+ yyfree((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * yylex() is called, initialization will occur. */
+ yy_init_globals( );
+
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (yyconst char * s )
+{
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *yyalloc (yy_size_t size )
+{
+ return (void *) malloc( size );
+}
+
+void *yyrealloc (void * ptr, yy_size_t size )
+{
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+}
+
+void yyfree (void * ptr )
+{
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 113 "pool_config.l"
+
+
+
+int pool_init_config(void)
+{
+ int res;
+ static char localhostname[256];
+ int i;
+
+ pool_config = palloc(sizeof(POOL_CONFIG));
+
+ memset(pool_config, 0, sizeof(POOL_CONFIG));
+
+#ifndef POOL_PRIVATE
+ pool_config->backend_desc = pool_shared_memory_create(sizeof(BackendDesc));
+ if (pool_config->backend_desc == NULL)
+ {
+ pool_error("failed to allocate pool_config->backend_desc");
+ return -1;
+ }
+#else
+ pool_config->backend_desc = palloc(sizeof(BackendDesc));
+#endif
+
+ /*
+ * add for watchdog
+ */
+ pool_config->other_wd = palloc0(sizeof(WdDesc));
+
+ /* set hardcoded default values */
+ pool_config->listen_addresses = "localhost";
+ pool_config->port = 9999;
+ pool_config->pcp_port = 9898;
+ pool_config->socket_dir = DEFAULT_SOCKET_DIR;
+ pool_config->pcp_socket_dir = DEFAULT_SOCKET_DIR;
+ pool_config->backend_socket_dir = NULL;
+ pool_config->pcp_timeout = 10;
+ pool_config->num_init_children = 32;
+ pool_config->listen_backlog_multiplier = 2;
+ pool_config->max_pool = 4;
+ pool_config->child_life_time = 300;
+ pool_config->client_idle_limit = 0;
+ pool_config->connection_life_time = 0;
+ pool_config->child_max_connections = 0;
+ pool_config->authentication_timeout = 60;
+ pool_config->logdir = DEFAULT_LOGDIR;
+ pool_config->logsyslog = 0;
+ pool_config->log_destination = "stderr";
+ pool_config->syslog_facility = LOG_LOCAL0;
+ pool_config->syslog_ident = "pgpool";
+ pool_config->pid_file_name = DEFAULT_PID_FILE_NAME;
+ pool_config->log_statement = 0;
+ pool_config->log_per_node_statement = 0;
+ pool_config->log_connections = 0;
+ pool_config->log_hostname = 0;
+ pool_config->enable_pool_hba = 0;
+ pool_config->pool_passwd = "pool_passwd";
+
+ pool_config->replication_mode = 0;
+ pool_config->load_balance_mode = 0;
+ pool_config->replication_stop_on_mismatch = 0;
+ pool_config->failover_if_affected_tuples_mismatch = 0;
+ pool_config->replicate_select = 0;
+ pool_config->reset_query_list = default_reset_query_list;
+ pool_config->num_reset_queries = sizeof(default_reset_query_list)/sizeof(char *);
+ pool_config->white_function_list = NULL;
+ pool_config->num_white_function_list = 0;
+ pool_config->black_function_list = default_black_function_list;
+ pool_config->num_black_function_list = sizeof(default_black_function_list)/sizeof(char *);
+ pool_config->print_timestamp = 1;
+ pool_config->log_error_verbosity = 1; /* PGERROR_DEFAULT */
+ pool_config->client_min_messages = 18; /* NOTICE */
+ pool_config->log_min_messages = 19; /* WARNING */
+ pool_config->print_user = 0;
+ pool_config->master_slave_mode = 0;
+ pool_config->master_slave_sub_mode = "slony";
+ pool_config->delay_threshold = 0;
+ pool_config->log_standby_delay = "none";
+ pool_config->connection_cache = 1;
+ pool_config->health_check_timeout = 20;
+ pool_config->health_check_period = 0;
+ pool_config->health_check_user = "nobody";
+ pool_config->health_check_password = "";
+ pool_config->health_check_max_retries = 0;
+ pool_config->health_check_retry_delay = 1;
+ pool_config->sr_check_period = 0;
+ pool_config->sr_check_user = "nobody";
+ pool_config->sr_check_password = "";
+ pool_config->failover_command = "";
+ pool_config->follow_master_command = "";
+ pool_config->failback_command = "";
+ pool_config->fail_over_on_backend_error = 1;
+ pool_config->insert_lock = 1;
+ pool_config->ignore_leading_white_space = 1;
+ pool_config->parallel_mode = 0;
+ pool_config->system_db_hostname = "localhost";
+ pool_config->system_db_port = 5432;
+ pool_config->system_db_dbname = "pgpool";
+ pool_config->system_db_schema = "pgpool_catalog";
+ pool_config->system_db_user = "pgpool";
+ pool_config->system_db_password = "";
+ pool_config->backend_desc->num_backends = 0;
+ pool_config->recovery_user = "";
+ pool_config->recovery_password = "";
+ pool_config->recovery_1st_stage_command = "";
+ pool_config->recovery_2nd_stage_command = "";
+ pool_config->recovery_timeout = 90;
+ pool_config->search_primary_node_timeout = 10;
+ pool_config->client_idle_limit_in_recovery = 0;
+ pool_config->lobj_lock_table = "";
+ pool_config->ssl = 0;
+ pool_config->ssl_cert = "";
+ pool_config->ssl_key = "";
+ pool_config->ssl_ca_cert = "";
+ pool_config->ssl_ca_cert_dir = "";
+ pool_config->debug_level = 0;
+ pool_config->relcache_expire = 0;
+ pool_config->relcache_size = 256;
+ pool_config->check_temp_table = 1;
+ pool_config->check_unlogged_table = 1;
+ pool_config->lists_patterns = NULL;
+ pool_config->pattc = 0;
+ pool_config->current_pattern_size = 0;
+ /*
+ * add for watchdog
+ */
+ pool_config->use_watchdog = 0;
+ pool_config->wd_lifecheck_method = MODE_HEARTBEAT;
+ pool_config->clear_memqcache_on_escalation = 1;
+ pool_config->wd_escalation_command = "";
+ pool_config->trusted_servers = "";
+ pool_config->delegate_IP = "";
+ res = gethostname(localhostname,sizeof(localhostname));
+ if(res !=0 )
+ {
+ pool_debug("failed to get this hostname");
+ }
+ pool_config->wd_hostname = localhostname;
+ pool_config->wd_port = 9000;
+ pool_config->other_wd->num_wd = 0;
+ pool_config->wd_interval = 10;
+ pool_config->wd_authkey = "";
+ pool_config->ping_path = "/bin";
+ pool_config->ifconfig_path = "/sbin";
+ pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0";
+ pool_config->if_down_cmd = "ifconfig eth0:0 down";
+ pool_config->arping_path = "/usr/sbin";
+ pool_config->arping_cmd = "arping -U $_IP_$ -w 1";
+ pool_config->wd_life_point = 3;
+ pool_config->wd_lifecheck_query = "SELECT 1";
+ pool_config->wd_lifecheck_dbname = "template1";
+ pool_config->wd_lifecheck_user = "nobody";
+ pool_config->wd_lifecheck_password = "";
+ pool_config->wd_heartbeat_port = 9694;
+ pool_config->wd_heartbeat_keepalive = 2;
+ pool_config->wd_heartbeat_deadtime = 30;
+ pool_config->num_hb_if = 0;
+
+ pool_config->memory_cache_enabled = 0;
+ pool_config->memqcache_method = "shmem";
+ pool_config->memqcache_memcached_host = "localhost";
+ pool_config->memqcache_memcached_port = 11211;
+ pool_config->memqcache_total_size = 67108864;
+ pool_config->memqcache_max_num_cache = 1000000;
+ pool_config->memqcache_expire = 0;
+ pool_config->memqcache_auto_cache_invalidation = 1;
+ pool_config->memqcache_maxcache = 409600;
+ pool_config->memqcache_cache_block_size = 1048576;
+ pool_config->memqcache_oiddir = "/var/log/pgpool/oiddir";
+ pool_config->white_memqcache_table_list = NULL;
+ pool_config->num_white_memqcache_table_list = 0;
+ pool_config->black_memqcache_table_list = NULL;
+ pool_config->num_black_memqcache_table_list = 0;
+ pool_config->lists_memqcache_table_patterns = NULL;
+ pool_config->memqcache_table_pattc = 0;
+ pool_config->current_memqcache_table_pattern_size = 0;
+
+ res = gethostname(localhostname,sizeof(localhostname));
+ if(res !=0 )
+ {
+ pool_debug("failed to get this hostname");
+ }
+ pool_config->pgpool2_hostname = localhostname;
+
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
+ {
+ clear_host_entry(i);
+ }
+ return 0;
+}
+
+/*
+ * Add regex expression to patterns array
+ * The supported type are: black_function_list and white_function_list
+ * Return 0 on error, 1 on success
+ */
+int add_regex_pattern(char *type, char *s)
+{
+ int regex_flags = REG_NOSUB;
+ RegPattern currItem;
+ /* force case insensitive pattern matching */
+ regex_flags |= REG_ICASE;
+ /* Add extended regex search */
+ regex_flags |= REG_EXTENDED;
+ /* Fill the pattern type */
+ if (strcmp(type, "black_function_list") == 0 ||
+ strcmp(type, "black_memqcache_table_list") == 0)
+ {
+ currItem.type = BLACKLIST;
+ }
+ else if (strcmp(type, "white_function_list") == 0 ||
+ strcmp(type, "white_memqcache_table_list") == 0)
+ {
+ currItem.type = WHITELIST;
+ }
+ else
+ {
+ pool_error("add_to_patterns: bad pattern type %s", type);
+ return 0;
+ }
+ /* Fill the pattern flag */
+ currItem.flag = regex_flags;
+
+ /* Fill pattern array */
+ currItem.pattern = palloc(sizeof(char)*(strlen(s)+3));
+ /* Force exact matching of function name with ^ and $ on the regex
+ if required to prevent partial matching. It also allow backward
+ compatibility.
+ */
+ if (strncmp(s, "^", 1) != 0) {
+ strncpy(currItem.pattern, "^", 2);
+ strncat(currItem.pattern, s, strlen(s) + 1);
+ } else {
+ strncpy(currItem.pattern, s, strlen(s) + 1);
+ }
+ if (s[strlen(s)-1] != '$') {
+ strncat(currItem.pattern, "$", 2);
+ }
+ pool_debug("add_to_patterns: regex pattern: %s", currItem.pattern);
+ /* compile our regex */
+ if (regcomp(&currItem.regexv, currItem.pattern, currItem.flag) != 0)
+ {
+ pool_error("add_to_patterns: invalid regex pattern: %s", currItem.pattern);
+ }
+ else if ((strcmp(type, "white_function_list") == 0 ||
+ strcmp(type, "black_function_list") == 0) &&
+ growFunctionPatternArray(currItem) < 0)
+ {
+ pool_error("add_to_patterns: unable to allocate new pattern");
+ return 0;
+ }
+ else if ((strcmp(type, "white_memqcache_table_list") == 0 ||
+ strcmp(type, "black_memqcache_table_list") == 0) &&
+ growMemqcacheTablePatternArray(currItem) < 0)
+ {
+ pool_error("add_to_patterns: unable to allocate new pattern");
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Dynamically grow the regex pattern array
+ * The array start with PATTERN_ARR_SIZE storage place, if required
+ * it will grow of PATTERN_ARR_SIZE more each time.
+ */
+int growFunctionPatternArray(RegPattern item)
+{
+ void *_tmp = NULL;
+ if (pool_config->pattc == pool_config->current_pattern_size)
+ {
+ pool_config->current_pattern_size += PATTERN_ARR_SIZE;
+ _tmp = repalloc(pool_config->lists_patterns,
+ (pool_config->current_pattern_size * sizeof(RegPattern)));
+ if (!_tmp)
+ {
+ return(-1);
+ }
+
+ pool_config->lists_patterns = (RegPattern*)_tmp;
+ }
+ pool_config->lists_patterns[pool_config->pattc] = item;
+ pool_config->pattc++;
+
+ return(pool_config->pattc);
+}
+
+int growMemqcacheTablePatternArray(RegPattern item)
+{
+ void *_tmp = NULL;
+ if (pool_config->memqcache_table_pattc == pool_config->current_memqcache_table_pattern_size)
+ {
+ pool_config->current_memqcache_table_pattern_size += PATTERN_ARR_SIZE;
+ _tmp = repalloc(pool_config->lists_memqcache_table_patterns,
+ (pool_config->current_memqcache_table_pattern_size * sizeof(RegPattern)));
+ if (!_tmp)
+ {
+ return(-1);
+ }
+
+ pool_config->lists_memqcache_table_patterns = (RegPattern*)_tmp;
+ }
+ pool_config->lists_memqcache_table_patterns[pool_config->memqcache_table_pattc] = item;
+ pool_config->memqcache_table_pattc++;
+
+ return(pool_config->memqcache_table_pattc);
+}
+
+int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
+{
+ FILE *fd;
+ int token;
+ char key[1024];
+ double total_weight;
+ int i;
+ bool log_destination_changed = false;
+#ifdef USE_MEMCACHED
+ bool use_memcached = true;
+#else
+ bool use_memcached = false;
+#endif
+
+#ifndef POOL_PRIVATE
+#define PARSE_ERROR() ereport(FATAL, \
+ (errmsg("syntex error in configuration file \"%s\"",POOL_CONF_FILE_NAME), \
+ errdetail("parse error at line %d '%s'", Lineno, yytext)))
+#else
+#define PARSE_ERROR() fprintf(stderr,"ERROR: syntex error in configuration file \"%s\"",POOL_CONF_FILE_NAME); \
+ fprintf(stderr,"DETAILS: parse error at line %d '%s'", Lineno, yytext)
+#endif
+
+ /* open config file */
+ fd = fopen(confpath, "r");
+ if (!fd)
+ {
+#ifndef POOL_PRIVATE
+ ereport(WARNING,
+ (errmsg("could not open configuration file \"%s\"\n",
+ POOL_CONF_FILE_NAME)));
+ ereport(NOTICE,
+ (errmsg("using default configuration parameter values")));
+#else
+ fprintf(stderr,"WARNING: could not open configuration file \"%s\"\n",
+ POOL_CONF_FILE_NAME);
+ fprintf(stderr,"NOTICE: using default configuration parameter values");
+#endif
+ return 0;
+ }
+
+ yyin = fd;
+ Lineno = 1;
+
+ for(;;)
+ {
+ token = yylex();
+ if (token == 0)
+ {
+ break;
+ }
+ if (token == POOL_PARSE_ERROR)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ if (token == POOL_EOL)
+ continue;
+
+ if (token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+
+ strlcpy(key, yytext, sizeof(key));
+
+#ifndef POOL_PRIVATE
+ ereport(DEBUG5,
+ (errmsg("key: %s", key)));
+#endif
+ token = yylex();
+
+ if (token == POOL_EQUALS)
+ token = yylex();
+
+#ifndef POOL_PRIVATE
+ ereport(DEBUG5,
+ (errmsg("value: %s kind: %d", yytext, token)));
+#endif
+ if (!strcmp(key, "allow_inet_domain_socket") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ /* for backward compatibility */
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ if (v)
+ pool_config->listen_addresses = pstrdup("*");
+ else
+ pool_config->listen_addresses = pstrdup("");
+ }
+ else if (!strcmp(key, "listen_addresses") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->listen_addresses = str;
+ }
+
+ else if (!strcmp(key, "port") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 1024)
+ {
+ pool_error("pool_config: %s must be 1024 or higher numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->port = v;
+ }
+ else if (!strcmp(key, "pcp_port") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 1024)
+ {
+ pool_error("pool_config: %s must be 1024 or higher numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->pcp_port = v;
+ }
+ else if (!strcmp(key, "socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->socket_dir = str;
+ }
+ else if (!strcmp(key, "pcp_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->pcp_socket_dir = str;
+ }
+ else if (!strcmp(key, "pcp_timeout") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or greater or equal to 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->pcp_timeout = v;
+ }
+ else if (!strcmp(key, "num_init_children") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 1)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->num_init_children = v;
+ }
+ else if (!strcmp(key, "listen_backlog_multiplier") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 1)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->listen_backlog_multiplier = v;
+ }
+ else if (!strcmp(key, "child_life_time") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->child_life_time = v;
+ }
+ else if (!strcmp(key, "client_idle_limit") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->client_idle_limit = v;
+ }
+ else if (!strcmp(key, "connection_life_time") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->connection_life_time = v;
+ }
+ else if (!strcmp(key, "child_max_connections") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->child_max_connections = v;
+ }
+ else if (!strcmp(key, "authentication_timeout") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->authentication_timeout = v;
+ }
+ else if (!strcmp(key, "max_pool") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->max_pool = v;
+ }
+ else if (!strcmp(key, "logdir") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->logdir = str;
+ }
+ else if (!strcmp(key, "log_destination") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ log_destination_changed = pool_config->log_destination != str;
+ pool_config->log_destination = str;
+ }
+ else if (!strcmp(key, "syslog_facility") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->syslog_facility = set_syslog_facility(str);
+ }
+ else if (!strcmp(key, "syslog_ident") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ log_destination_changed = log_destination_changed || pool_config->syslog_ident != str;
+ pool_config->syslog_ident = str;
+ }
+ else if (!strcmp(key, "pid_file_name") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->pid_file_name = str;
+ }
+ else if (!strcmp(key, "log_connections") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->log_connections = v;
+ }
+ else if (!strcmp(key, "log_hostname") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->log_hostname = v;
+ }
+ else if (!strcmp(key, "enable_pool_hba") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->enable_pool_hba = v;
+ }
+ else if (!strcmp(key, "pool_passwd") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->pool_passwd = str;
+ }
+
+ else if (!strcmp(key, "backend_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ pool_log("pool_config: backend_socket_dir is deprecated, please use backend_hostname");
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->backend_socket_dir = str;
+ }
+ else if (!strcmp(key, "replication_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->replication_mode = v;
+
+ if (pool_config->master_slave_mode && pool_config->replication_mode)
+ {
+ pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time");
+ fclose(fd);
+ return(-1);
+ }
+
+ }
+ else if (!strcmp(key, "load_balance_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->load_balance_mode = v;
+ }
+ else if (!strcmp(key, "replication_stop_on_mismatch") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_debug("replication_stop_on_mismatch: %d", v);
+ pool_config->replication_stop_on_mismatch = v;
+ }
+ else if (!strcmp(key, "failover_if_affected_tuples_mismatch") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_debug("failover_if_affected_tuples_mismatch: %d", v);
+ pool_config->failover_if_affected_tuples_mismatch = v;
+ }
+ else if (!strcmp(key, "replicate_select") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_debug("replicate_select: %d", v);
+ pool_config->replicate_select = v;
+ }
+ else if (!strcmp(key, "reset_query_list") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->reset_query_list = extract_string_tokens(str, ";", &pool_config->num_reset_queries);
+ if (pool_config->reset_query_list == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ }
+
+ else if (!strcmp(key, "white_function_list") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->white_function_list =
+ extract_string_tokens(str, ",", &pool_config->num_white_function_list);
+
+ if (pool_config->white_function_list == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ for (i=0;i<pool_config->num_white_function_list;i++)
+ {
+ add_regex_pattern("white_function_list", pool_config->white_function_list[i]);
+ }
+ }
+
+ else if (!strcmp(key, "black_function_list") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->black_function_list =
+ extract_string_tokens(str, ",", &pool_config->num_black_function_list);
+
+ if (pool_config->black_function_list == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ for (i=0;i<pool_config->num_black_function_list;i++)
+ {
+ add_regex_pattern("black_function_list", pool_config->black_function_list[i]);
+ }
+ }
+ else if (!strcmp(key, "log_error_verbosity") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str, *valid_val;
+ int i;
+ const char *ordered_valid_values[] = {"terse","default","verbose",NULL};
+ bool found = false;
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ for(i=0; ; i++)
+ {
+ valid_val = (char*)ordered_valid_values[i];
+ if(!valid_val)
+ break;
+ if (!strcasecmp(str, valid_val))
+ {
+ found = true;
+ pool_config->log_error_verbosity = i;
+ break;
+ }
+ }
+ if (!found)
+ {
+ pool_error("pool_config: invalid log_error_verbosity %s", key);
+ fclose(fd);
+ return(-1);
+ }
+ }
+
+ else if (!strcmp(key, "client_min_messages") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str, *valid_val;
+ int i;
+ const char *ordered_valid_values[] = {"debug5","debug4","debug3","debug2","debug1","log","commerror","info","notice","warning","error",NULL};
+ bool found = false;
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ for(i=0; ; i++)
+ {
+ valid_val = (char*)ordered_valid_values[i];
+ if(!valid_val)
+ break;
+
+ if (!strcasecmp(str, valid_val))
+ {
+ found = true;
+ pool_config->client_min_messages = i + 10;
+ break;
+ }
+ }
+ if (!found)
+ {
+ pool_error("pool_config: invalid client_min_messages %s", key);
+ fclose(fd);
+ return(-1);
+ }
+ }
+ else if (!strcmp(key, "log_min_messages") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str, *valid_val;
+ int i;
+ const char *ordered_valid_values[] = {"debug5","debug4","debug3","debug2","debug1","log","commerror","info","notice","warning","error","fatal","panic",NULL};
+ bool found = false;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ for(i=0; ; i++)
+ {
+ valid_val = (char*)ordered_valid_values[i];
+ if(!valid_val)
+ break;
+
+ if (!strcasecmp(str, valid_val))
+ {
+ found = true;
+ pool_config->log_min_messages = i + 10; /* error codes start with 10 */
+ break;
+ }
+ }
+ if (!found)
+ {
+ pool_error("pool_config: invalid log_min_messages %s", key);
+ fclose(fd);
+ return(-1);
+ }
+ }
+
+ else if (!strcmp(key, "print_timestamp") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->print_timestamp = v;
+ }
+ else if (!strcmp(key, "print_user") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->print_user = v;
+ }
+
+ else if (!strcmp(key, "master_slave_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->master_slave_mode = v;
+
+ if (pool_config->master_slave_mode && pool_config->replication_mode)
+ {
+ pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time");
+ fclose(fd);
+ return(-1);
+ }
+ }
+
+ else if (!strcmp(key, "master_slave_sub_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+
+ if (strcmp(str, MODE_SLONY) && strcmp(str, MODE_STREAMREP))
+ {
+ pool_error("pool_config: %s must be either \"slony\" or \"stream\"", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->master_slave_sub_mode = str;
+ }
+
+ else if (!strcmp(key, "delay_threshold") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ long long int v = atol(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->delay_threshold = v;
+ }
+
+ else if (!strcmp(key, "log_standby_delay") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+
+ if (strcmp(str, "always") && strcmp(str, "if_over_threshold") && strcmp(str, "none"))
+ {
+ pool_error("pool_config: invalid log_standby_delay %s", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->log_standby_delay = str;
+ }
+
+ else if (!strcmp(key, "connection_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->connection_cache = v;
+ }
+
+ else if (!strcmp(key, "health_check_timeout") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->health_check_timeout = v;
+ }
+
+ else if (!strcmp(key, "health_check_period") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->health_check_period = v;
+ }
+
+ else if (!strcmp(key, "health_check_user") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->health_check_user = str;
+ }
+
+ else if (!strcmp(key, "health_check_password") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->health_check_password = str;
+ }
+
+ else if (!strcmp(key, "health_check_max_retries") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->health_check_max_retries = v;
+ }
+
+ else if (!strcmp(key, "health_check_retry_delay") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->health_check_retry_delay = v;
+ }
+
+ else if (!strcmp(key, "sr_check_period") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_period = v;
+ }
+
+ else if (!strcmp(key, "sr_check_user") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_user = str;
+ }
+
+ else if (!strcmp(key, "sr_check_password") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->sr_check_password = str;
+ }
+
+ else if (!strcmp(key, "failover_command") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->failover_command = str;
+ }
+
+ else if (!strcmp(key, "follow_master_command") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->follow_master_command = str;
+ }
+
+ else if (!strcmp(key, "failback_command") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->failback_command = str;
+ }
+
+ else if (!strcmp(key, "fail_over_on_backend_error") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->fail_over_on_backend_error = v;
+ }
+
+ else if (!strcmp(key, "recovery_user") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->recovery_user = str;
+ }
+
+ else if (!strcmp(key, "recovery_password") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->recovery_password = str;
+ }
+
+ else if (!strcmp(key, "recovery_1st_stage_command") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->recovery_1st_stage_command = str;
+ }
+
+ else if (!strcmp(key, "recovery_2nd_stage_command") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->recovery_2nd_stage_command = str;
+ }
+
+ else if (!strcmp(key, "recovery_timeout") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->recovery_timeout = v;
+ }
+
+ else if (!strcmp(key, "search_primary_node_timeout") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->search_primary_node_timeout = v;
+ }
+
+ else if (!strcmp(key, "client_idle_limit_in_recovery") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < -1)
+ {
+ pool_error("pool_config: %s must be greater or equal to -1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->client_idle_limit_in_recovery = v;
+ }
+
+ else if (!strcmp(key, "insert_lock") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->insert_lock = v;
+ }
+
+ else if (!strcmp(key, "ignore_leading_white_space") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->ignore_leading_white_space = v;
+ }
+
+ else if (!strcmp(key, "parallel_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->parallel_mode = v;
+ }
+
+ else if (!strcmp(key, "pgpool2_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->pgpool2_hostname = str;
+ }
+
+ else if (!strcmp(key, "system_db_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->system_db_hostname = str;
+ }
+
+ else if (!strcmp(key, "system_db_port") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->system_db_port = v;
+ }
+
+ else if (!strcmp(key, "system_db_dbname") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->system_db_dbname = str;
+ }
+
+ else if (!strcmp(key, "system_db_schema") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->system_db_schema = str;
+ }
+
+ else if (!strcmp(key, "system_db_user") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->system_db_user = str;
+ }
+
+ else if (!strcmp(key, "system_db_password") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->system_db_password = str;
+ }
+
+ else if (!strncmp(key, "backend_hostname", 16) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+ char *str;
+
+ slot = atoi(key + 16);
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: backend number %s for backend_hostname out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if (context == INIT_CONFIG ||
+ (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED))
+ strlcpy(BACKEND_INFO(slot).backend_hostname, str, MAX_DB_HOST_NAMELEN);
+ }
+
+ else if (!strncmp(key, "backend_port", 12) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+
+ slot = atoi(key + 12);
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: host number %s for port number out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_debug("pool_config: port slot number %d ", slot);
+ if (context == INIT_CONFIG)
+ {
+ BACKEND_INFO(slot).backend_port = atoi(yytext);
+ BACKEND_INFO(slot).backend_status = CON_CONNECT_WAIT;
+ }
+ else if (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED)
+ {
+ BACKEND_INFO(slot).backend_port = atoi(yytext);
+ BACKEND_INFO(slot).backend_status = CON_DOWN;
+ }
+ }
+
+ else if (!strncmp(key, "backend_weight", 14) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+ double v;
+ BACKEND_STATUS status;
+
+ slot = atoi(key + 14);
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: weight number %s for port number out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ v = atof(yytext);
+
+ if (v < 0.0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+
+ pool_debug("pool_config: weight slot number %d weight: %f", slot, v);
+ status = BACKEND_INFO(slot).backend_status;
+
+ if (context == INIT_CONFIG || context == RELOAD_CONFIG)
+ {
+ double old_v = BACKEND_INFO(slot).unnormalized_weight;
+ BACKEND_INFO(slot).unnormalized_weight = v;
+
+ /*
+ * Log weight change event only when context is
+ * reloading of pgpool.conf and weight is actually
+ * changed
+ */
+ if (context == RELOAD_CONFIG && old_v != v)
+ {
+ pool_log("Backend weight for backend%d changed from %f to %f. This will take effect from next client session.", slot, old_v, v);
+ }
+ }
+ }
+ else if (!strncmp(key, "backend_data_directory", 22) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+ char *str;
+ BACKEND_STATUS status;
+
+ slot = atoi(key + 22);
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: backend number %s for backend_data_directory out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ status = BACKEND_INFO(slot).backend_status;
+ if (context == INIT_CONFIG ||
+ (context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN)))
+ strlcpy(BACKEND_INFO(slot).backend_data_directory, str, MAX_PATH_LENGTH);
+ }
+ else if (!strncmp(key, "backend_flag", 12) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ char *str;
+ char **flags;
+ int n;
+ int i;
+ int slot;
+ unsigned short flag = 0;
+ bool allow_to_failover_is_specified = 0;
+ bool disallow_to_failover_is_specified = 0;
+
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ pool_error("pool_config: extract_string failed: %s", yytext);
+ fclose(fd);
+ return(-1);
+ }
+
+ flags = extract_string_tokens(str, "|", &n);
+ if (!flags || n < 0)
+ {
+ pool_debug("pool_config: unable to get backend flags");
+ fclose(fd);
+ return(-1);
+ }
+
+ for (i=0;i<n;i++)
+ {
+ if (!strcmp(flags[i], "ALLOW_TO_FAILOVER"))
+ {
+ if (disallow_to_failover_is_specified)
+ {
+ pool_error("pool_config: cannot set ALLOW_TO_FAILOVER and DISALLOW_TO_FAILOVER at the same time");
+ fclose(fd);
+ return(-1);
+ }
+ flag &= ~POOL_FAILOVER;
+ allow_to_failover_is_specified = true;
+ pool_debug("pool_config: allow_to_failover on");
+ }
+
+ else if (!strcmp(flags[i], "DISALLOW_TO_FAILOVER"))
+ {
+ if (allow_to_failover_is_specified)
+ {
+ pool_error("pool_config: cannot set ALLOW_TO_FAILOVER and DISALLOW_TO_FAILOVER at the same time");
+ fclose(fd);
+ return(-1);
+ }
+ flag |= POOL_FAILOVER;
+ disallow_to_failover_is_specified = true;
+ pool_debug("pool_config: disallow_to_failover on");
+ }
+
+ else
+ {
+ pool_error("pool_config: invalid backend flag:%s", flags[i]);
+ }
+ }
+
+ slot = atoi(key + 12);
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: slot number %s for flag out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ BACKEND_INFO(slot).flag = flag;
+
+ pool_debug("pool_config: slot number %d flag: %04x", slot, flag);
+ }
+
+ else if (!strcmp(key, "log_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ return(-1);
+ }
+ pool_config->log_statement = v;
+ }
+ else if (!strcmp(key, "log_per_node_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ return(-1);
+ }
+ pool_config->log_per_node_statement = v;
+ }
+
+ else if (!strcmp(key, "lobj_lock_table") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->lobj_lock_table = str;
+ }
+ /*
+ * add for watchdog
+ */
+ else if (!strncmp(key, "other_pgpool_hostname", 21) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+ char *str;
+
+ slot = atoi(key + 21) ;
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: pgpool number %s for other_pgpool_hostname out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+ strlcpy(WD_INFO(slot).hostname, str, WD_MAX_HOST_NAMELEN);
+ }
+
+ else if (!strncmp(key, "other_pgpool_port", 17) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+
+ slot = atoi(key + 17);
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: pgpool number %s for other_pgpool_port out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+ WD_INFO(slot).pgpool_port = atoi(yytext);
+ }
+
+ else if (!strncmp(key, "other_wd_port", 13) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+
+ slot = atoi(key + 13);
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
+ {
+ pool_error("pool_config: pgpool number %s for other_wd_port out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+ {
+ WD_INFO(slot).wd_port = atoi(yytext);
+ WD_INFO(slot).status = WD_INIT;
+ pool_config->other_wd->num_wd = slot + 1;
+ }
+ }
+ else if (!strcmp(key, "use_watchdog") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->use_watchdog = v;
+ }
+
+ else if (!strcmp(key, "clear_memqcache_on_escalation") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->clear_memqcache_on_escalation = v;
+ }
+
+ else if (!strcmp(key, "wd_escalation_command") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_escalation_command = str;
+ }
+
+ else if (!strcmp(key, "trusted_servers") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->trusted_servers = str;
+ }
+ else if (!strcmp(key, "delegate_IP") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->delegate_IP = str;
+ }
+ else if (!strcmp(key, "wd_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->wd_hostname = str;
+ }
+ else if (!strcmp(key, "wd_port") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v <= 0)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_port = v;
+ }
+ else if (!strcmp(key, "wd_interval") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v <= 0)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_interval = v;
+ }
+ else if (!strcmp(key, "ping_path") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->ping_path = str;
+ }
+ else if (!strcmp(key, "ifconfig_path") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->ifconfig_path = str;
+ }
+ else if (!strcmp(key, "if_up_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->if_up_cmd = str;
+ }
+ else if (!strcmp(key, "if_down_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->if_down_cmd = str;
+ }
+ else if (!strcmp(key, "arping_path") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->arping_path = str;
+ }
+ else if (!strcmp(key, "arping_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->arping_cmd = str;
+ }
+ else if (!strcmp(key, "wd_life_point") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v <= 0)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_life_point = v;
+ }
+ else if (!strcmp(key, "wd_lifecheck_query") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if(strlen(str))
+ pool_config->wd_lifecheck_query = str;
+ }
+
+ else if (!strcmp(key, "wd_lifecheck_dbname") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_lifecheck_dbname = str;
+ }
+
+ else if (!strcmp(key, "wd_lifecheck_user") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_lifecheck_user = str;
+ }
+
+ else if (!strcmp(key, "wd_lifecheck_password") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_lifecheck_password = str;
+ }
+
+ else if (!strcmp(key, "wd_lifecheck_method") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+
+ if (strcmp(str, MODE_HEARTBEAT) && strcmp(str, MODE_QUERY))
+ {
+ pool_error("pool_config: %s must be either \"heartbeat\" or \"query\"", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_lifecheck_method = str;
+ }
+ else if (!strcmp(key, "wd_heartbeat_port") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v <= 0)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_heartbeat_port = v;
+ }
+ else if (!strcmp(key, "wd_heartbeat_keepalive") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v <= 0)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_heartbeat_keepalive = v;
+ }
+ else if (!strcmp(key, "wd_heartbeat_deadtime") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v <= 0)
+ {
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_heartbeat_deadtime = v;
+ }
+ else if (!strcmp(key, "wd_authkey") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->wd_authkey = str;
+ }
+
+ else if (!strncmp(key, "heartbeat_device", 16) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+ char *str;
+
+ slot = atoi(key + 16) ;
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
+ {
+ pool_error("pool_config: pgpool number %s for heartbeat_device out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+ strlcpy(WD_HB_IF(slot).if_name, str, WD_MAX_IF_NAME_LEN);
+
+ }
+ /* this must be prior to hertbeat_destination */
+ else if (!strncmp(key, "heartbeat_destination_port", 26) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+
+ slot = atoi(key + 26) ;
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
+ {
+ pool_error("pool_config: pgpool number %s for heartbeat_destination_port out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+ {
+ WD_HB_IF(slot).dest_port = atoi(yytext);
+ pool_config->num_hb_if = slot + 1;
+ }
+ }
+ else if (!strncmp(key, "heartbeat_destination", 21) &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
+ mypid == getpid()) /* this parameter must be modified by parent pid */
+ {
+ int slot;
+ char *str;
+
+ slot = atoi(key + 21) ;
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
+ {
+ pool_error("pool_config: pgpool number %s for heartbeat_destination out of range", key);
+ fclose(fd);
+ return(-1);
+ }
+
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
+ strlcpy(WD_HB_IF(slot).addr, str, WD_MAX_HOST_NAMELEN);
+ }
+
+ else if (!strcmp(key, "ssl") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ return(-1);
+ }
+ pool_config->ssl = v;
+ }
+ else if (!strcmp(key, "ssl_cert") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->ssl_cert = str;
+ }
+ else if (!strcmp(key, "ssl_key") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->ssl_key = str;
+ }
+ else if (!strcmp(key, "ssl_ca_cert") &&
+ CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->ssl_ca_cert = str;
+ }
+ else if (!strcmp(key, "ssl_ca_cert_dir") &&
+ CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->ssl_ca_cert_dir = str;
+ }
+
+ else if (!strcmp(key, "debug_level") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ /* Consider -d option value stored in pool_config already */
+ pool_config->debug_level |= v;
+ }
+
+ else if (!strcmp(key, "relcache_expire") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->relcache_expire = v;
+ }
+
+ else if (!strcmp(key, "relcache_size") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 1)
+ {
+ pool_error("pool_config: %s must be equal or higher than 1 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->relcache_size = v;
+ }
+
+ else if (!strcmp(key, "check_temp_table") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ return(-1);
+ }
+ pool_config->check_temp_table = v;
+ }
+
+ else if (!strcmp(key, "check_unlogged_table") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ return(-1);
+ }
+ pool_config->check_unlogged_table = v;
+ }
+
+ else if (!strcmp(key, "memory_cache_enabled") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memory_cache_enabled = v;
+ }
+ else if (!strcmp(key, "memqcache_method") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+
+ if (!strcmp(str, "memcached") && !use_memcached)
+ {
+ pool_error("memqcached_method cannot be memcached because pgpool-II is not built with MEMCACHED enabled");
+ fclose(fd);
+ return -1;
+ }
+
+ if (strcmp(str, "memcached") && strcmp(str, "shmem"))
+ {
+ pool_error("memqcached_method must be either shmem or memcached");
+ fclose(fd);
+ return -1;
+ }
+
+ pool_config->memqcache_method = str;
+ }
+ else if (!strcmp(key, "memqcache_memcached_host") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_memcached_host = str;
+ }
+ else if (!strcmp(key, "memqcache_memcached_port") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_memcached_port = v;
+ }
+ else if (!strcmp(key, "memqcache_total_size") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_total_size = v;
+ }
+ else if (!strcmp(key, "memqcache_max_num_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_max_num_cache = v;
+ }
+ else if (!strcmp(key, "memqcache_expire") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_expire = v;
+ }
+ else if (!strcmp(key, "memqcache_auto_cache_invalidation") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = eval_logical(yytext);
+
+ if (v < 0)
+ {
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_auto_cache_invalidation = v;
+ }
+ else if (!strcmp(key, "memqcache_maxcache") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 0)
+ {
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_maxcache = v;
+ }
+ else if (!strcmp(key, "memqcache_cache_block_size") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ int v = atoi(yytext);
+
+ if (token != POOL_INTEGER || v < 512)
+ {
+ pool_error("pool_config: %s must be equal or higher than 512 numeric value", key);
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_cache_block_size = v;
+ }
+ else if (!strcmp(key, "memqcache_oiddir") && CHECK_CONTEXT(INIT_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->memqcache_oiddir = str;
+ }
+ else if (!strcmp(key, "white_memqcache_table_list") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->white_memqcache_table_list =
+ extract_string_tokens(str, ",", &pool_config->num_white_memqcache_table_list);
+
+ if (pool_config->white_memqcache_table_list == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ for (i=0;i<pool_config->num_white_memqcache_table_list;i++)
+ {
+ add_regex_pattern("white_memqcache_table_list", pool_config->white_memqcache_table_list[i]);
+ }
+ }
+
+ else if (!strcmp(key, "black_memqcache_table_list") &&
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
+ {
+ char *str;
+
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
+ {
+ PARSE_ERROR();
+ fclose(fd);
+ return(-1);
+ }
+ str = extract_string(yytext, token);
+ if (str == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ pool_config->black_memqcache_table_list =
+ extract_string_tokens(str, ",", &pool_config->num_black_memqcache_table_list);
+
+ if (pool_config->black_memqcache_table_list == NULL)
+ {
+ fclose(fd);
+ return(-1);
+ }
+ for (i=0;i<pool_config->num_black_memqcache_table_list;i++)
+ {
+ add_regex_pattern("black_memqcache_table_list", pool_config->black_memqcache_table_list[i]);
+ }
+ }
+ }
+
+ fclose(fd);
+
+ if (log_destination_changed)
+ {
+ /* log_destination has changed, we need to open syslog or close it */
+ if (!strcmp(pool_config->log_destination, "stderr"))
+ {
+ closelog();
+ pool_config->logsyslog = 0;
+ }
+ else
+ {
+ openlog(pool_config->syslog_ident, LOG_PID|LOG_NDELAY|LOG_NOWAIT, pool_config->syslog_facility);
+ pool_config->logsyslog = 1;
+ }
+ }
+
+ pool_config->backend_desc->num_backends = 0;
+ total_weight = 0.0;
+
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
+ {
+ /* port number == 0 indicates that this server is out of use */
+ if (BACKEND_INFO(i).backend_port == 0)
+ {
+ clear_host_entry(i);
+ }
+
+ else
+ {
+ total_weight += BACKEND_INFO(i).unnormalized_weight;
+ pool_config->backend_desc->num_backends = i+1;
+
+ /* initialize backend_hostname with a default socket path if empty */
+ if (*(BACKEND_INFO(i).backend_hostname) == '\0')
+ {
+ if (pool_config->backend_socket_dir == NULL)
+ {
+ pool_debug("pool_config: empty backend_hostname%d, use PostgreSQL's default unix socket path (%s)", i, DEFAULT_SOCKET_DIR);
+ strlcpy(BACKEND_INFO(i).backend_hostname, DEFAULT_SOCKET_DIR, MAX_DB_HOST_NAMELEN);
+ }
+ else /* DEPRECATED. backward compatibility with older version. Use backend_socket_dir*/
+ {
+ pool_debug("pool_config: empty backend_hostname%d, use backend_socket_dir as unix socket path (%s)", i, pool_config->backend_socket_dir);
+ strlcpy(BACKEND_INFO(i).backend_hostname, pool_config->backend_socket_dir, MAX_DB_HOST_NAMELEN);
+ }
+ }
+ }
+ }
+
+ pool_debug("num_backends: %d total_weight: %f",
+ pool_config->backend_desc->num_backends, total_weight);
+ /*
+ * Normalize load balancing weights. What we are doing here is,
+ * assign 0 to RAND_MAX to each backend's weight according to the
+ * value weightN. For example, if two backends are assigned 1.0,
+ * then each backend will get RAND_MAX/2 normalized weight.
+ */
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
+ {
+#ifdef DEBUG
+ print_host_entry(i);
+#endif
+
+ if (BACKEND_INFO(i).backend_port != 0)
+ {
+ BACKEND_INFO(i).backend_weight =
+ (RAND_MAX) * BACKEND_INFO(i).unnormalized_weight / total_weight;
+ pool_debug("backend %d weight: %f", i, BACKEND_INFO(i).backend_weight);
+ pool_debug("backend %d flag: %04x", i, BACKEND_INFO(i).flag);
+ }
+ }
+
+ /* initialize system_db_hostname with a default socket path if empty */
+ if (*pool_config->system_db_hostname == '\0')
+ {
+ pool_debug("pool_config: empty system_db_hostname, use PostgreSQL's default unix socket path (%s)", DEFAULT_SOCKET_DIR);
+ strlcpy(pool_config->system_db_hostname, DEFAULT_SOCKET_DIR, MAX_DB_HOST_NAMELEN);
+ }
+
+ if (pool_config->parallel_mode)
+ {
+#ifndef POOL_PRIVATE
+ int dist_num;
+#endif
+ SystemDBInfo *info;
+
+ system_db_info = palloc(sizeof(POOL_SYSTEMDB_CONNECTION_POOL));
+ memset(system_db_info, 0, sizeof(*system_db_info));
+
+#ifndef POOL_PRIVATE
+ system_db_info->system_db_status = pool_shared_memory_create(sizeof(BACKEND_STATUS));
+#else
+ system_db_info->system_db_status = palloc(sizeof(BACKEND_STATUS));
+#endif
+
+ *system_db_info->system_db_status = CON_CONNECT_WAIT; /* which is the same as SYSDB_STATUS = CON_CONNECT_WAIT */
+
+ info = palloc(sizeof(SystemDBInfo));
+
+ system_db_info->info = info;
+ info->hostname = pool_config->system_db_hostname;
+ info->port = pool_config->system_db_port;
+ info->user = pool_config->system_db_user;
+ info->password = pool_config->system_db_password;
+ info->database_name = pool_config->system_db_dbname;
+ info->schema_name = pool_config->system_db_schema;
+ info->dist_def_num = 0;
+ info->dist_def_slot = NULL;
+
+#ifndef POOL_PRIVATE
+ if (pool_config->parallel_mode)
+ {
+
+ dist_num = pool_memset_system_db_info(info);
+ if(dist_num < 0)
+ {
+ pool_error("failed to get systemdb info");
+ return(-1);
+ }
+ if (!pool_config->replication_mode && !pool_config->load_balance_mode)
+ {
+ pool_error("pool_config: parallel_mode requires replication_mode or load_balance_mode turned on");
+ return(-1);
+ }
+ }
+ SYSDB_STATUS = CON_UP;
+#endif
+ }
+
+ if (strcmp(pool_config->recovery_1st_stage_command, "") ||
+ strcmp(pool_config->recovery_2nd_stage_command, ""))
+ {
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
+ {
+ if (pool_config->backend_desc->backend_info[i].backend_port != 0 &&
+ !strcmp(pool_config->backend_desc->backend_info[i].backend_data_directory, ""))
+ {
+ pool_error("pool_config: recovery_1st_stage_command and recovery_2nd_stage_command requires backend_data_directory to be set");
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static char *extract_string(char *value, POOL_TOKEN token)
+{
+ char *ret;
+
+ ret = pstrdup(value);
+
+ if (token == POOL_STRING)
+ {
+ ret[strlen(ret)-1] = '\0';
+ return (ret+1);
+ }
+ return ret;
+}
+
+/*
+ * Try to interpret value as boolean value. Valid values are: true,
+ * false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
+ * If the string parses okay, return true, else false.
+ * If okay and result is not NULL, return the value in *result.
+ * This function copied from PostgreSQL source code.
+ */
+static bool parse_bool_with_len(const char *value, size_t len, bool *result)
+{
+ switch (*value)
+ {
+ case 't':
+ case 'T':
+ if (strncasecmp(value, "true", len) == 0)
+ {
+ if (result)
+ *result = true;
+ return true;
+ }
+ break;
+ case 'f':
+ case 'F':
+ if (strncasecmp(value, "false", len) == 0)
+ {
+ if (result)
+ *result = false;
+ return true;
+ }
+ break;
+ case 'y':
+ case 'Y':
+ if (strncasecmp(value, "yes", len) == 0)
+ {
+ if (result)
+ *result = true;
+ return true;
+ }
+ break;
+ case 'n':
+ case 'N':
+ if (strncasecmp(value, "no", len) == 0)
+ {
+ if (result)
+ *result = false;
+ return true;
+ }
+ break;
+ case 'o':
+ case 'O':
+ /* 'o' is not unique enough */
+ if (strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
+ {
+ if (result)
+ *result = true;
+ return true;
+ }
+ else if (strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
+ {
+ if (result)
+ *result = false;
+ return true;
+ }
+ break;
+ case '1':
+ if (len == 1)
+ {
+ if (result)
+ *result = true;
+ return true;
+ }
+ break;
+ case '0':
+ if (len == 1)
+ {
+ if (result)
+ *result = false;
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (result)
+ *result = false; /* suppress compiler warning */
+ return false;
+}
+
+int eval_logical(char *str)
+{
+ bool result;
+
+ if (!parse_bool_with_len(str, strlen(str), &result))
+ return -1;
+
+ return (result ? 1 : 0);
+}
+
+/*
+ * Extract tokens separated by delimi from str. Return value is an
+ * array of pointers to malloced strings. number of tokens is set to
+ * n; note that str will be destroyed by strtok().
+ */
+#define MAXTOKENS 1024
+static char **extract_string_tokens(char *str, char *delimi, int *n)
+{
+ char *token;
+ static char **tokens;
+
+ *n = 0;
+
+ tokens = palloc(MAXTOKENS*sizeof(char *));
+
+ for (token = strtok(str, delimi); token != NULL && *n < MAXTOKENS; token = strtok(NULL, delimi))
+ {
+ tokens[*n] = pstrdup(token);
+ pool_debug("extract_string_tokens: token: %s", tokens[*n]);
+ (*n)++;
+ }
+ return tokens;
+}
+
+static void clear_host_entry(int slot)
+{
+ *pool_config->backend_desc->backend_info[slot].backend_hostname = '\0';
+ pool_config->backend_desc->backend_info[slot].backend_port = 0;
+ pool_config->backend_desc->backend_info[slot].backend_status = CON_UNUSED;
+ pool_config->backend_desc->backend_info[slot].backend_weight = 0.0;
+}
+
+#ifdef DEBUG
+static void print_host_entry(int slot)
+{
+ pool_debug("slot: %d host: %s port: %d status: %d weight: %f",
+ slot,
+ pool_config->server_hostnames[slot],
+ pool_config->server_ports[slot],
+ pool_config->server_status[slot],
+ pool_config->server_weights[slot]);
+}
+#endif
+
+/* Use to set the syslog facility level if logsyslog is activated */
+int set_syslog_facility(char *value)
+{
+ int facility = LOG_LOCAL0;
+
+ if (value == NULL)
+ return facility;
+
+ if (strncmp(value, "LOCAL", 5) == 0 && strlen(value) == 6) {
+ switch (value[5]) {
+ case '0':
+ facility = LOG_LOCAL0;
+ break;
+ case '1':
+ facility = LOG_LOCAL1;
+ break;
+ case '2':
+ facility = LOG_LOCAL2;
+ break;
+ case '3':
+ facility = LOG_LOCAL3;
+ break;
+ case '4':
+ facility = LOG_LOCAL4;
+ break;
+ case '5':
+ facility = LOG_LOCAL5;
+ break;
+ case '6':
+ facility = LOG_LOCAL6;
+ break;
+ case '7':
+ facility = LOG_LOCAL7;
+ break;
+ }
+ }
+ return facility;
+}
+
+/*
+ * Translate binary form of backend flag to string.
+ * The returned data is in static buffer, and it will be destroyed
+ * at the next call to this function.
+ */
+char *pool_flag_to_str(unsigned short flag)
+{
+ static char buf[1024]; /* should be large enough */
+
+ if (POOL_ALLOW_TO_FAILOVER(flag))
+ snprintf(buf, sizeof(buf), "ALLOW_TO_FAILOVER");
+ else if (POOL_DISALLOW_TO_FAILOVER(flag))
+ snprintf(buf, sizeof(buf), "DISALLOW_TO_FAILOVER");
+ return buf;
+}
+
diff --git a/src/context/pool_query_context.c b/src/context/pool_query_context.c
index 6212650b9..caa4d3aea 100644
--- a/src/context/pool_query_context.c
+++ b/src/context/pool_query_context.c
@@ -175,7 +175,7 @@ void pool_setall_node_to_be_sent(POOL_QUERY_CONTEXT *query_context)
int i;
POOL_SESSION_CONTEXT *sc;
- sc = pool_get_session_context();
+ sc = pool_get_session_context(true);
if (!sc)
{
pool_error("pool_setall_node_to_be_sent: no session context");
diff --git a/src/libs/pcp/Makefile.am b/src/libs/pcp/Makefile.am
index 56dff4b55..07f5a31ae 100644
--- a/src/libs/pcp/Makefile.am
+++ b/src/libs/pcp/Makefile.am
@@ -4,7 +4,8 @@ lib_LTLIBRARIES = libpcp.la
libpcp_la_SOURCES = pcp.c $(top_srcdir)/src/utils/pcp/pcp_stream.c \
$(top_srcdir)/src/utils/pcp/pcp_error.c \
$(top_srcdir)/src/utils/pcp/pcp_timeout.c \
- $(top_srcdir)/src/auth/md5.c
+ $(top_srcdir)/src/auth/md5.c \
+ $(top_srcdir)/src/utils/strlcpy.c
include_HEADERS = $(top_srcdir)/src/include/pcp/pcp.h \
$(top_srcdir)/src/include/pcp/libpcp_ext.h \
diff --git a/src/libs/pcp/Makefile.in b/src/libs/pcp/Makefile.in
index 2f88a58a1..4fa158437 100644
--- a/src/libs/pcp/Makefile.in
+++ b/src/libs/pcp/Makefile.in
@@ -128,7 +128,7 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libpcp_la_LIBADD =
am_libpcp_la_OBJECTS = pcp.lo pcp_stream.lo pcp_error.lo \
- pcp_timeout.lo md5.lo
+ pcp_timeout.lo md5.lo strlcpy.lo
libpcp_la_OBJECTS = $(am_libpcp_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -327,7 +327,8 @@ lib_LTLIBRARIES = libpcp.la
libpcp_la_SOURCES = pcp.c $(top_srcdir)/src/utils/pcp/pcp_stream.c \
$(top_srcdir)/src/utils/pcp/pcp_error.c \
$(top_srcdir)/src/utils/pcp/pcp_timeout.c \
- $(top_srcdir)/src/auth/md5.c
+ $(top_srcdir)/src/auth/md5.c \
+ $(top_srcdir)/src/utils/strlcpy.c
include_HEADERS = $(top_srcdir)/src/include/pcp/pcp.h \
$(top_srcdir)/src/include/pcp/libpcp_ext.h \
@@ -418,6 +419,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_error.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_stream.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcp_timeout.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -469,11 +471,11 @@ md5.lo: $(top_srcdir)/src/auth/md5.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o md5.lo `test -f '$(top_srcdir)/src/auth/md5.c' || echo '$(srcdir)/'`$(top_srcdir)/src/auth/md5.c
strlcpy.lo: $(top_srcdir)/src/utils/strlcpy.c
-@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcpy.lo -MD -MP -MF $(DEPDIR)/strlcpy.Tpo -c -o strlcpy.lo `test -f '$(top_srcdir)/src/utils/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/src/utils/strlcpy.c
-@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/strlcpy.Tpo $(DEPDIR)/strlcpy.Plo
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/src/utils/strlcpy.c' object='strlcpy.lo' libtool=yes @AMDEPBACKSLASH@
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT strlcpy.lo -MD -MP -MF $(DEPDIR)/strlcpy.Tpo -c -o strlcpy.lo `test -f '$(top_srcdir)/src/utils/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/src/utils/strlcpy.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/strlcpy.Tpo $(DEPDIR)/strlcpy.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$(top_srcdir)/src/utils/strlcpy.c' object='strlcpy.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strlcpy.lo `test -f '$(top_srcdir)/src/utils/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/src/utils/strlcpy.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strlcpy.lo `test -f '$(top_srcdir)/src/utils/strlcpy.c' || echo '$(srcdir)/'`$(top_srcdir)/src/utils/strlcpy.c
mostlyclean-libtool:
-rm -f *.lo
diff --git a/src/libs/pcp/pcp.c b/src/libs/pcp/pcp.c
index a93bda742..ba4445a52 100644
--- a/src/libs/pcp/pcp.c
+++ b/src/libs/pcp/pcp.c
@@ -1017,7 +1017,6 @@ free_systemdb_info(SystemDBInfo * si)
if (si == NULL)
return;
-
pfree(si->hostname);
pfree(si->user);
pfree(si->password);
diff --git a/src/main/main.c b/src/main/main.c
index fa83a7489..7dc144caf 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -529,13 +529,15 @@ char *get_config_file_name(void)
}
/*
- * get_config_file_name: return full path of pool_hba.conf.
+ * get_hba_file_name: return full path of pool_hba.conf.
*/
char *get_hba_file_name(void)
{
return hba_file;
}
-/* Call back function to unlink the file */
+/*
+ * Call back function to unlink the file
+ */
static void FileUnlink(int code, Datum path)
{
char* filePath = (char*)path;
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index 2d472fd8d..ea945b14e 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -5,7 +5,7 @@
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2013 PgPool Global Development Group
+ * Copyright (c) 2003-2014 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
@@ -701,6 +701,7 @@ static int create_inet_domain_socket(const char *hostname, const int port)
}
backlog = pool_config->num_init_children * pool_config->listen_backlog_multiplier;
+
if (backlog > PGPOOLMAXLITSENQUEUELENGTH)
backlog = PGPOOLMAXLITSENQUEUELENGTH;
@@ -984,10 +985,10 @@ static RETSIGTYPE exit_handler(int sig)
processState = EXITING;
/* Close listen socket */
- pool_log("pgpool main: close listen socket");
- close(inet_fd);
- close(unix_fd);
-
+ pool_log("pgpool main: close listen socket");
+ close(inet_fd);
+ close(unix_fd);
+
for (i = 0; i < pool_config->num_init_children; i++)
{
pid_t pid = process_info[i].pid;
@@ -1154,17 +1155,18 @@ static void failover(void)
/* failback request? */
if (Req_info->kind == NODE_UP_REQUEST)
{
- if (node_id < 0 || node_id >= MAX_NUM_BACKENDS ||
+ if (node_id < 0 || node_id >= MAX_NUM_BACKENDS ||
(Req_info->kind == NODE_UP_REQUEST && !(RAW_MODE &&
BACKEND_INFO(node_id).backend_status == CON_DOWN) && VALID_BACKEND(node_id)) ||
(Req_info->kind == NODE_DOWN_REQUEST && !VALID_BACKEND(node_id)))
{
pool_semaphore_unlock(REQUEST_INFO_SEM);
- if (node_id < 0 || node_id >= MAX_NUM_BACKENDS)
- pool_error("failover_handler: invalid node_id %d MAX_NUM_BACKENDS: %d", node_id, MAX_NUM_BACKENDS);
- else
- pool_error("failover_handler: invalid node_id %d status:%d MAX_NUM_BACKENDS: %d", node_id,
- BACKEND_INFO(node_id).backend_status, MAX_NUM_BACKENDS);
+
+ if (node_id < 0 || node_id >= MAX_NUM_BACKENDS)
+ pool_error("failover_handler: invalid node_id %d MAX_NUM_BACKENDS: %d", node_id, MAX_NUM_BACKENDS);
+ else
+ pool_error("failover_handler: invalid node_id %d status:%d MAX_NUM_BACKENDS: %d", node_id,
+ BACKEND_INFO(node_id).backend_status, MAX_NUM_BACKENDS);
kill(pcp_pid, SIGUSR2);
switching = 0;
Req_info->switching = false;
diff --git a/src/protocol/child.c b/src/protocol/child.c
index 24f6b0941..d7a53d8d8 100644
--- a/src/protocol/child.c
+++ b/src/protocol/child.c
@@ -101,11 +101,11 @@ static volatile sig_atomic_t alarm_enabled = false;
static int idle; /* non 0 means this child is in idle state */
static int accepted = 0;
+fd_set readmask;
+int nsocks;
static int child_inet_fd = 0;
static int child_unix_fd = 0;
-fd_set readmask;
-int nsocks;
extern int myargc;
extern char **myargv;
@@ -1454,7 +1454,6 @@ POOL_CONNECTION_POOL_SLOT *make_persistent_db_connection(
ereport(ERROR,
(errmsg("failed to make persistent db connection"),
errdetail("connection to %s(%d) failed", hostname, port)));
-
}
cp->con = pool_open(fd,true);
@@ -1550,17 +1549,17 @@ void free_persisten_db_connection_memory(POOL_CONNECTION_POOL_SLOT *cp)
return;
if (!cp->sp)
{
- free(cp);
+ pfree(cp);
return;
}
if (cp->sp->startup_packet)
- free(cp->sp->startup_packet);
+ pfree(cp->sp->startup_packet);
if (cp->sp->database)
- free(cp->sp->database);
+ pfree(cp->sp->database);
if (cp->sp->user)
- free(cp->sp->user);
- free(cp->sp);
- free(cp);
+ pfree(cp->sp->user);
+ pfree(cp->sp);
+ pfree(cp);
}
/*
diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c
index d803c0945..487f715df 100644
--- a/src/protocol/pool_proto_modules.c
+++ b/src/protocol/pool_proto_modules.c
@@ -2051,12 +2051,7 @@ POOL_STATUS ParameterDescription(POOL_CONNECTION *frontend,
int num_params, send_num_params, num_dmy;
char kind = 't';
- session_context = pool_get_session_context();
- if (!session_context)
- {
- pool_error("ParameterDescription: cannot get session context");
- return POOL_END;
- }
+ session_context = pool_get_session_context(false);
/* only in replication mode and rewritten query */
if (!REPLICATION || !session_context->query_context->rewritten_query)
diff --git a/src/tools/pgmd5/Makefile.am b/src/tools/pgmd5/Makefile.am
index 904cb5c48..bd4942464 100644
--- a/src/tools/pgmd5/Makefile.am
+++ b/src/tools/pgmd5/Makefile.am
@@ -10,6 +10,5 @@ pg_md5_SOURCES = pg_md5.c \
$(top_srcdir)/src/config/pool_config_md5.c \
$(top_srcdir)/src/main/pool_globals.c
-
DEFS = @DEFS@ \
-DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS