pgpool2.git / summary / log / commit / refs
commit cb2be04704e6bc6811d31b370d8afb67ee2a7aa9
Author: Yoshiyuki Asaba <y-asaba at pgfoundry.org>
Date: Wed Feb 20 10:12:41 2008 +0000
Return TRUE in is_select_query() if a query is "COPY TO STDOUT".
kind mismatching error was caused by pg_dump or pg_dumpall.
Per report by Bruno Lustosa.
pool_process_query.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/pool_process_query.c b/pool_process_query.c
index 76b8db499..791095e21 100644
--- a/pool_process_query.c
+++ b/pool_process_query.c
@@ -4169,26 +4169,34 @@ static int load_balance_enabled(POOL_CONNECTION_POOL *backend, Node* node, char
/*
* return non 0 if SQL is SELECT statement.
+ * COPY TO STDOUT is OK too.
*/
static int is_select_query(Node *node, char *sql)
{
- SelectStmt *select_stmt;
-
- if (node == NULL || !IsA(node, SelectStmt))
+ if (node == NULL)
return 0;
- select_stmt = (SelectStmt *)node;
- if (select_stmt->intoClause || select_stmt->lockingClause)
- return 0;
+ if (IsA(node, SelectStmt))
+ {
+ SelectStmt *select_stmt = (SelectStmt *)node;
+ if (select_stmt->intoClause || select_stmt->lockingClause)
+ return 0;
- if (pool_config->ignore_leading_white_space)
+ if (pool_config->ignore_leading_white_space)
+ {
+ /* ignore leading white spaces */
+ while (*sql && isspace(*sql))
+ sql++;
+ }
+ return (*sql == 's' || *sql == 'S' || *sql == '(');
+ }
+ else if (IsA(node, CopyStmt))
{
- /* ignore leading white spaces */
- while (*sql && isspace(*sql))
- sql++;
+ CopyStmt *copy_stmt = (CopyStmt *)node;
+ return (copy_stmt->is_from == FALSE &&
+ copy_stmt->filename == NULL);
}
-
- return (*sql == 's' || *sql == 'S' || *sql == '(');
+ return 0;
}
/*
[parent: fda5128e025b]