From: Tatsuo Ishii Date: Sun, 4 Jun 2006 10:03:30 +0000 (+0000) Subject: Add log_statement option. patches contributed by Thomas E X-Git-Tag: V3_1~9 X-Git-Url: http://git.postgresql.org/gitweb/static/%7B%7Bpguslink%28?a=commitdiff_plain;h=de66da0ba8cd27bbd2e3f33869645a4a45c24307;p=pgpool1.git Add log_statement option. patches contributed by Thomas E Lackey, modifications and documents by Tatsuo --- diff --git a/ChangeLog b/ChangeLog index 0112cc2..559ed0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-XX-XX + * Version 3.1 + * Improve documentation. patches contributed by Mark Stosberg + * Fix "kind is 0!" error in Execute(). Reads messages until + receiving CommandComplete, EmptyQuery, ErrorResponse or + PortalSuspend in Execute() (Yoshiyuki) + * Add log_statement option. patches contributed by Thomas E + Lackey, modifications and documents by Tatsuo + 2006-05-17 * Version 3.0.2 * pgpool does not exit even if pgpool.conf contents is wrong(Tatsuo) diff --git a/README b/README index 4281a80..be4e696 100644 --- a/README +++ b/README @@ -473,6 +473,12 @@ pgpool version 3.0 README balnced. This is usefull for certain APIs such as DBI/DBD which is know as adding an extra leading white space. + log_statement + + If true, print all statements to the log. Like the log_statement option + to PostgreSQL, this allows for observing queries without engaging in full + debugging. + 7. Starting pgpool The simplist way to start pgpool is: diff --git a/README.euc_jp b/README.euc_jp index 7bdbadc..ac46adb 100644 --- a/README.euc_jp +++ b/README.euc_jp @@ -664,6 +664,12 @@ pgpool version 3.0(kalekale) README ¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤òÄɲ乤ë¤è¤¦¤ÊAPI¤ò»È¤¤¡¢¥í¡¼¥É¥Ð¥é¥ó¥¹¤·¤¿¤¤¤È¤­¤Ë Í­¸ú¤Ç¤¹¡£ + log_statement + + true¤Ê¤é¤ÐSQLʸ¤ò¥í¥°½ÐÎϤ·¤Þ¤¹¡¥¤³¤ÎÌòÌܤÏPostgreSQL¤Î + log_statement¥ª¥×¥·¥ç¥ó¤È»÷¤Æ¤¤¤Æ¡¤¥Ç¥Ð¥Ã¥°¥ª¥×¥·¥ç¥ó¤¬¤Ê¤¤¤È¤­¤Ç¤â + Ì䤤¹ç¤ï¤»¤ò¥í¥°½ÐÎϤ·¤ÆÄ´¤Ù¤ë¤³¤È¤¬¤Ç¤­¤ë¤Î¤ÇÊØÍø¤Ç¤¹¡¥ + 7. pgpool¤Îµ¯Æ° pgpool¤òµ¯Æ°¤¹¤ë¤â¤Ã¤È¤â´Êñ¤ÊÊýË¡¤Ï¡¤ diff --git a/pgpool.conf.sample b/pgpool.conf.sample index 328fbc5..18c39ba 100644 --- a/pgpool.conf.sample +++ b/pgpool.conf.sample @@ -117,3 +117,8 @@ insert_lock = false # is useful for certain APIs such as DBI/DBD which is known to adding an # extra leading white space. ignore_leading_white_space = false + +# If true, print all statements to the log. Like the log_statement option +# to PostgreSQL, this allows for observing queries without engaging in full +# debugging. +log_statement = false diff --git a/pool.h b/pool.h index 1af8acd..542bb31 100644 --- a/pool.h +++ b/pool.h @@ -158,6 +158,7 @@ typedef struct { int num_reset_queries; /* number of queries in reset_query_list */ int num_servers; /* number of PostgreSQL servers */ int server_status[MAX_CONNECTION_SLOTS]; /* server status 0:unused, 1:up, 2:down */ + int log_statement; /* 0:false, 1: true - logs all SQL statements */ } POOL_CONFIG; #define MAX_PASSWORD_SIZE 1024 diff --git a/pool_config.c b/pool_config.c index 827ec1c..2afa696 100644 --- a/pool_config.c +++ b/pool_config.c @@ -1675,6 +1675,7 @@ int pool_get_config(char *confpath) pool_config.health_check_user = "nobody"; pool_config.insert_lock = 0; pool_config.num_servers = 0; + pool_config.log_statement = 0; #define PARSE_ERROR() pool_error("pool_config: parse error at line %d '%s'", Lineno, yytext) /* open config file */ @@ -2142,6 +2143,17 @@ int pool_get_config(char *confpath) } pool_config.ignore_leading_white_space = v; } + else if (!strcmp(key, "log_statement")) + { + 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; + } } if (pool_config.backend_port) diff --git a/pool_config.l b/pool_config.l index e68f0c8..54ba958 100644 --- a/pool_config.l +++ b/pool_config.l @@ -137,6 +137,7 @@ int pool_get_config(char *confpath) pool_config.health_check_user = "nobody"; pool_config.insert_lock = 0; pool_config.num_servers = 0; + pool_config.log_statement = 0; #define PARSE_ERROR() pool_error("pool_config: parse error at line %d '%s'", Lineno, yytext) /* open config file */ @@ -604,6 +605,17 @@ int pool_get_config(char *confpath) } pool_config.ignore_leading_white_space = v; } + else if (!strcmp(key, "log_statement")) + { + 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; + } } if (pool_config.backend_port) diff --git a/pool_process_query.c b/pool_process_query.c index e2be8f6..ce7aab2 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -571,7 +571,15 @@ static POOL_STATUS Query(POOL_CONNECTION *frontend, string = query; } - pool_debug("Query: %s", string); + /* log query to log file if neccessary */ + if (pool_config.log_statement) + { + pool_log("statement: %s", string); + } + else + { + pool_debug("statement: %s", string); + } /* * if this is DROP DATABASE command, send HUP signal to parent and