postgresql-pgpool-II/pgpool-II-3.0-fix-segfault-of-child-on-syntax-error-ext_query_prot.patch
2012-02-01 19:57:31 +04:00

74 lines
2.7 KiB
Diff

diff --git a/pool_proto_modules.c b/pool_proto_modules.c
index aad5a01..d254896 100644
--- a/pool_proto_modules.c
+++ b/pool_proto_modules.c
@@ -1,6 +1,6 @@
/* -*-pgsql-c-*- */
/*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.c,v 1.85 2010/08/30 03:55:58 kitagawa Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.c,v 1.86 2010/09/27 02:01:57 kitagawa Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -164,10 +164,8 @@ POOL_STATUS SimpleQuery(POOL_CONNECTION *frontend,
* The command will be sent to all backends in replication mode
* or master/primary in master/slave mode.
*/
- char *p = "DELETE FROM foo WHERE col = 'pgpool: unable to parse the query'";
-
pool_log("SimpleQuery: Unable to parse the query: %s", contents);
- parse_tree_list = raw_parser(p);
+ parse_tree_list = raw_parser(POOL_DUMMY_QUERY);
}
if (parse_tree_list != NIL)
@@ -615,13 +613,25 @@ POOL_STATUS Parse(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
old_context = pool_memory;
pool_memory = query_context->memory_context;
+ /* parse SQL string */
parse_tree_list = raw_parser(stmt);
+
if (parse_tree_list == NIL)
{
- /* free_parser(); */
- ;
+ /*
+ * Unable to parse the query. Probably syntax error or the
+ * query is too new and our parser cannot understand. Treat as
+ * if it were an DELETE command. Note that the DELETE command
+ * does not execute, instead the original query will be sent
+ * to backends, which may or may not cause an actual syntax errors.
+ * 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", contents);
+ parse_tree_list = raw_parser(POOL_DUMMY_QUERY);
}
- else
+
+ if (parse_tree_list != NIL)
{
/* Save last query string for logging purpose */
snprintf(query_string_buffer, sizeof(query_string_buffer), "Parse: %s", stmt);
diff --git a/pool_proto_modules.h b/pool_proto_modules.h
index 903a42d..d07e689 100644
--- a/pool_proto_modules.h
+++ b/pool_proto_modules.h
@@ -1,7 +1,7 @@
/* -*-pgsql-c-*- */
/*
*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.h,v 1.23 2010/08/26 09:23:06 kitagawa Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_proto_modules.h,v 1.24 2010/09/27 02:01:57 kitagawa Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -35,6 +35,7 @@
#include "pool_session_context.h"
#define SPECIFIED_ERROR 1
+#define POOL_DUMMY_QUERY "DELETE FROM foo WHERE col = 'pgpool: unable to parse the query'"
#define POOL_ERROR_QUERY "send invalid query from pgpool to abort transaction"
extern char *copy_table; /* copy table name */