pgpool2.git / summary / log / commit / refs
commit 7da8835e8a71a5dd83c6b4e8e6db03bf3f50d574
Author: Tatsuo Ishii <ishii at sraoss.co.jp>
Date: Tue Dec 30 12:16:53 2008 +0000
Enhance "kind mismatch" error message to include original query.
This would not work for extended query, though.
pool.h | 3 +++
pool_process_query.c | 6 +++++-
pool_proto_modules.c | 13 +++++++++++++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/pool.h b/pool.h
index 42705e04b..f79c2893e 100644
--- a/pool.h
+++ b/pool.h
@@ -421,6 +421,9 @@ extern volatile sig_atomic_t *InRecovery;
extern char remote_ps_data[]; /* used for set_ps_display */
extern volatile sig_atomic_t got_sighup;
+#define QUERY_STRING_BUFFER_LEN 1024
+extern char query_string_buffer[]; /* last query string sent to simpleQuery() */
+
/*
* public functions
*/
diff --git a/pool_process_query.c b/pool_process_query.c
index 7f72d00e5..a9c829000 100644
--- a/pool_process_query.c
+++ b/pool_process_query.c
@@ -3460,7 +3460,11 @@ POOL_STATUS read_kind_from_backend(POOL_CONNECTION *frontend, POOL_CONNECTION_PO
if (degenerate_node_num)
{
- String *msg = init_string("kind mismatch among backends");
+ String *msg = init_string("kind mismatch among backends. ");
+
+ string_append_char(msg, "possible last query was: \"");
+ string_append_char(msg, query_string_buffer);
+ string_append_char(msg, "\" kind details are:");
for (i=0;i<NUM_BACKENDS;i++)
{
diff --git a/pool_proto_modules.c b/pool_proto_modules.c
index dc0af95f7..42777488f 100644
--- a/pool_proto_modules.c
+++ b/pool_proto_modules.c
@@ -75,6 +75,16 @@ PreparedStatementList prepared_list; /* prepared statement name list */
int is_select_pgcatalog = 0;
int is_select_for_update = 0; /* 1 if SELECT INTO or SELECT FOR UPDATE */
bool is_parallel_table = false;
+
+/*
+ * last query string sent to simpleQuery()
+ */
+char query_string_buffer[QUERY_STRING_BUFFER_LEN];
+
+/*
+ * query string produced by nodeToString() in simpleQuery().
+ * this variable only usefull when enable_query_cache is true.
+ */
char *parsed_query = NULL;
POOL_STATUS NotificationResponse(POOL_CONNECTION *frontend,
@@ -154,6 +164,9 @@ POOL_STATUS NotificationResponse(POOL_CONNECTION *frontend,
string = query;
}
+ /* save last query string for logging purpose */
+ strncpy(query_string_buffer, string, sizeof(query_string_buffer));
+
/* show ps status */
query_ps_status(string, backend);
[parent: 9e61b0f57150]