Skip to content

Commit

Permalink
Fix is_select_query() not to allow cursor statements.
Browse files Browse the repository at this point in the history
Close() should not allowed since hold cursor + update
may cause data inconsistency.
  • Loading branch information
t-ishii committed Nov 29, 2009
1 parent b23c062 commit 2af75e5
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions pool_process_query.c
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*-pgsql-c-*- */ /* -*-pgsql-c-*- */
/* /*
* $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.175 2009/11/29 08:42:18 t-ishii Exp $ * $Header: /cvsroot/pgpool/pgpool-II/pool_process_query.c,v 1.176 2009/11/29 11:56:59 t-ishii Exp $
* *
* pgpool: a language independent connection pool server for PostgreSQL * pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii * written by Tatsuo Ishii
Expand Down Expand Up @@ -2297,11 +2297,8 @@ int load_balance_enabled(POOL_CONNECTION_POOL *backend, Node* node, char *sql)
* returns non 0 if the SQL statement can be load * returns non 0 if the SQL statement can be load
* balanced. Followings are statemnts go into this category. * balanced. Followings are statemnts go into this category.
* *
* - SELECT without FOR UPDATE/SHARE * - SELECT/WITH without FOR UPDATE/SHARE
* - COPY TO STDOUT * - COPY TO STDOUT
* - DECLARE..SELECT (without INTO nor FOR UPDATE/SHARE)
* - FETCH
* - CLOSE
* *
* note that for SELECT INTO, this function returns 0 * note that for SELECT INTO, this function returns 0
*/ */
Expand Down Expand Up @@ -2330,27 +2327,17 @@ int is_select_query(Node *node, char *sql)
sql++; sql++;
} }


if (IsA(node, SelectStmt) || IsA(node, DeclareCursorStmt)) if (IsA(node, SelectStmt))
{ {
SelectStmt *select_stmt; SelectStmt *select_stmt;


if (IsA(node, SelectStmt)) select_stmt = (SelectStmt *)node;
select_stmt = (SelectStmt *)node;
else
select_stmt = (SelectStmt *)((DeclareCursorStmt *)node)->query;


if (select_stmt->intoClause || select_stmt->lockingClause) if (select_stmt->intoClause || select_stmt->lockingClause)
return 0; return 0;


if (IsA(node, SelectStmt)) return (*sql == 's' || *sql == 'S' || *sql == '(' ||
return (*sql == 's' || *sql == 'S' || *sql == '(' || *sql == 'w' || *sql == 'W' || *sql == 't' || *sql == 'T');
*sql == 'w' || *sql == 'W' || *sql == 't' || *sql == 'T');
else
return (*sql == 'd' || *sql == 'D');
}
else if (IsA(node, FetchStmt) || IsA(node, ClosePortalStmt))
{
return (*sql == 'f' || *sql == 'F' || *sql == 'c' || *sql == 'C');
} }
else if (IsA(node, CopyStmt)) else if (IsA(node, CopyStmt))
{ {
Expand Down

0 comments on commit 2af75e5

Please sign in to comment.