Add log_statement option. patches contributed by Thomas E
authorTatsuo Ishii <ishii at sraoss.co.jp>
Sun, 4 Jun 2006 10:03:30 +0000 (10:03 +0000)
committerTatsuo Ishii <ishii at sraoss.co.jp>
Sun, 4 Jun 2006 10:03:30 +0000 (10:03 +0000)
 Lackey, modifications and documents by Tatsuo

ChangeLog
README
README.euc_jp
pgpool.conf.sample
pool.h
pool_config.c
pool_config.l
pool_process_query.c

index 0112cc2772a2502203aa21d8cd9927fdd5aaa58d..559ed0f17703634dd8b7739094e366f8edc8b480 100644 (file)
--- 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    <ishii@sraoss.co.jp>
        * Version 3.0.2
        * pgpool does not exit even if pgpool.conf contents is wrong(Tatsuo)
diff --git a/README b/README
index 4281a80af19568bbbecc0b81a561de1ed4827342..be4e6969d190bb78b2aa64cf133cf1ecb3793c4f 100644 (file)
--- 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:
index 7bdbadc8ec6ac01aef9260096af772e1b2d5d40d..ac46adbef775105dc23e3523e25613d517514751 100644 (file)
@@ -664,6 +664,12 @@ pgpool version 3.0(kalekale) README
    ¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤òÄɲ乤ë¤è¤¦¤ÊAPI¤ò»È¤¤¡¢¥í¡¼¥É¥Ð¥é¥ó¥¹¤·¤¿¤¤¤È¤­¤Ë
    Í­¸ú¤Ç¤¹¡£
 
+   log_statement
+
+   true¤Ê¤é¤ÐSQLʸ¤ò¥í¥°½ÐÎϤ·¤Þ¤¹¡¥¤³¤ÎÌòÌܤÏPostgreSQL¤Î
+   log_statement¥ª¥×¥·¥ç¥ó¤È»÷¤Æ¤¤¤Æ¡¤¥Ç¥Ð¥Ã¥°¥ª¥×¥·¥ç¥ó¤¬¤Ê¤¤¤È¤­¤Ç¤â
+   Ì䤤¹ç¤ï¤»¤ò¥í¥°½ÐÎϤ·¤ÆÄ´¤Ù¤ë¤³¤È¤¬¤Ç¤­¤ë¤Î¤ÇÊØÍø¤Ç¤¹¡¥
+
 7. pgpool¤Îµ¯Æ°
 
    pgpool¤òµ¯Æ°¤¹¤ë¤â¤Ã¤È¤â´Êñ¤ÊÊýË¡¤Ï¡¤
index 328fbc58c48af856b6f40cd2b07c98b8e8ead8ea..18c39ba7a425d1a7b1676bd8c1e526e2502f0f85 100644 (file)
@@ -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 1af8acdee050213419c8165f56b5fc4476edbc53..542bb31360bd4ed527567dae59369e71bcf7da34 100644 (file)
--- 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
index 827ec1c2f1e52d8e7868359fc30ffe21a84d76b4..2afa6966b9eadc9d247240221f75eb884cd3a208 100644 (file)
@@ -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)
index e68f0c82f100d4cb9e6ee615c385590bddd6df5c..54ba9584a3b722e57acfebccea97d52298ef339e 100644 (file)
@@ -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)
index e2be8f60e502807c3c276d20877690165773648c..ce7aab2c274af82c5ada6b503ea0e9d1be5254c1 100644 (file)
@@ -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