pgpool2.git / summary / log / commit / refs

commit    ce4f1e536e2e872bee75c7bb1f6185ce96247374
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Mon Nov 21 22:43:01 2011 +0000

    Log client IP and port number when pgpool failed to parse given query.
    This is usefull to identify which client gives wrong query without
    enabling log_connections, which produces too many log entries
    on busy web systems.


child.c | 6 +++--- pool.h | 3 +++ pool_proto_modules.c | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/child.c b/child.c index 773b5c295..3dfa460ce 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 aa745bd04..7932ec4ca 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 9773693d1..5d13b13ea 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); } } [parent: 40eaaef705ff]