Permalink
Browse files

Allow to load balance EXPLAIN and EXPLAIN ANALYZE (only if query is

SELECT). This will prevent kind mismatch errors when query plan are
different among servers.
  • Loading branch information...
1 parent 90e3377 commit fa2315e73b76e4943d85e7eca81885b418f36a15 t-ishii committed Dec 7, 2009
Showing with 16 additions and 1 deletion.
  1. +16 −1 pool_process_query.c
View
@@ -1,6 +1,6 @@
/* -*-pgsql-c-*- */
/*
- * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.180 2009/12/06 08:46:34 t-ishii Exp $
+ * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.181 2009/12/07 08:11:58 t-ishii Exp $
*
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
@@ -1827,6 +1827,8 @@ int load_balance_enabled(POOL_CONNECTION_POOL *backend, Node* node, char *sql)
*
* - SELECT/WITH without FOR UPDATE/SHARE
* - COPY TO STDOUT
+ * - EXPLAIN
+ * - EXPLAIN ANALYZE and query is SELECT
*
* note that for SELECT INTO, this function returns 0
*/
@@ -1873,6 +1875,19 @@ int is_select_query(Node *node, char *sql)
return (copy_stmt->is_from == FALSE &&
copy_stmt->filename == NULL);
}
+ else if (IsA(node, ExplainStmt))
+ {
+ ExplainStmt * explain_stmt = (ExplainStmt *)node;
+
+ if (explain_stmt->analyze)
+ {
+ Node *query = explain_stmt->query;
+
+ return (IsA(query, SelectStmt));
+ }
+ else
+ return 1;
+ }
return 0;
}

0 comments on commit fa2315e

Please sign in to comment.