>>> By enabling "log_connections" you have your client IP and pgpool child
>>> pid in your log. Since the log for "unable parse..." includes pgpool
>>> child pid, you can get client IP by checking pgpool child pid.
>>>
>>> LOG:   pid 4327: connection received: host=[local]
>>> LOG:   pid 4327: SimpleQuery: Unable to parse the query: select select;
>> 
>> I was hoping there was some way other than enabling log_connections,
>> as that's going to log every single connection (millions/day), even if
>> there's no error?
> 
> Good suggestion. I would like to include it for next release (3.2)
> unless someone beats me.

Here is the patch I promised. Here are sample log entries.

From TCP/IP client case:
2011-11-20 21:15:52 LOG:   pid 23045: SimpleQuery: Unable to parse the query: 
"select select;" from client 127.0.0.1(33737)

From Unix domain socket client case:
2011-11-20 21:14:46 LOG:   pid 23045: SimpleQuery: Unable to parse the query: 
"select select;" from local client

Comments?
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp
diff --git a/child.c b/child.c
index 773b5c2..3dfa460 100644
--- a/child.c
+++ b/child.c
@@ -90,6 +90,9 @@ char remote_ps_data[NI_MAXHOST];		/* used for set_ps_display */
 
 volatile sig_atomic_t got_sighup = 0;
 
+char remote_host[NI_MAXHOST];	/* client host */
+char remote_port[NI_MAXSERV];	/* client port */
+
 /*
 * child main loop
 */
@@ -480,9 +483,6 @@ static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *time
 	struct timeval *timeoutval;
 	struct timeval tv1, tv2, tmback = {0, 0};
 
-	char remote_host[NI_MAXHOST];
-	char remote_port[NI_MAXSERV];
-
 	set_ps_display("wait for connection request", false);
 
 	/* Destroy session context for just in case... */
diff --git a/pool.h b/pool.h
index aa745bd..7932ec4 100644
--- a/pool.h
+++ b/pool.h
@@ -412,6 +412,9 @@ extern char query_string_buffer[];		/* last query string sent to simpleQuery() *
 
 extern BACKEND_STATUS private_backend_status[MAX_NUM_BACKENDS];
 
+extern char remote_host[];	/* client host */
+extern char remote_port[];	/* client port */
+
 /*
  * public functions
  */
diff --git a/pool_proto_modules.c b/pool_proto_modules.c
index 9773693..5d13b13 100644
--- a/pool_proto_modules.c
+++ b/pool_proto_modules.c
@@ -197,7 +197,14 @@ POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend,
 			 * The command will be sent to all backends in replication mode
 			 * or master/primary in master/slave mode.
 			 */
-			pool_log("SimpleQuery: Unable to parse the query: %s", contents);
+			if (!strcmp(remote_host, "[local]"))
+			{
+				pool_log("SimpleQuery: Unable to parse the query: \"%s\" from local client", contents);
+			}
+			else
+			{
+				pool_log("SimpleQuery: Unable to parse the query: \"%s\" from client %s(%s)", contents, remote_host, remote_port);
+			}
 			parse_tree_list = raw_parser(POOL_DUMMY_WRITE_QUERY);
 		}
 	}
@@ -752,7 +759,14 @@ POOL_STATUS Parse(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
 			 * The command will be sent to all backends in replication mode
 			 * or master/primary in master/slave mode.
 			 */
-			pool_log("Parse: Unable to parse the query: %s", stmt);
+			if (!strcmp(remote_host, "[local]"))
+			{
+				pool_log("Parse: Unable to parse the query: \"%s\" from local client", stmt);
+			}
+			else
+			{
+				pool_log("Parse: Unable to parse the query: \"%s\" from client %s(%s)", stmt, remote_host, remote_port);
+			}
 			parse_tree_list = raw_parser(POOL_DUMMY_WRITE_QUERY);
 		}
 	}
_______________________________________________
Pgpool-general mailing list
[email protected]
http://pgfoundry.org/mailman/listinfo/pgpool-general

Reply via email to