pgpool2.git / summary / log / commit / refs
commit 94e55a2831fb6231799023b7332cf603ecb72071
Author: Yoshiharu Mori <y-mori at sraoss.co.jp>
Date: Fri Nov 30 07:38:40 2007 +0000
Fix: The INSERT statment did not correspond to the parser of postgresql 8.3
that pgpool-II 2.0 had.
Therefore, the following errors occur if INSERT is done in a parallel mode
ERROR: pgpool2 sql restriction
DETAIL: cannot use SElectStmt in InserStmt
pool_rewrite_query.c | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/pool_rewrite_query.c b/pool_rewrite_query.c
index 17cb87c65..5716a877a 100644
--- a/pool_rewrite_query.c
+++ b/pool_rewrite_query.c
@@ -52,28 +52,33 @@ static int getInsertRule(ListCell *lc,List *list_t ,DistDefInfo *info,int div_ke
{
int loop_counter = 0;
int node_number = -1;
+ ListCell *cell;
- foreach(lc,list_t)
+ if(list_t->length != 1)
+ return -1;
+
+ cell = list_head(list_t);
+
+ if(!cell && !IsA(cell,List))
+ return 1;
+
+ foreach(lc,lfirst(cell))
{
- Node *n;
- ResTarget *target;
A_Const *constant;
Value value;
void *obj = NULL;
- n = lfirst(lc);
- target = (ResTarget *) n;
+ obj = lfirst(lc);
- if(target->val && IsA(target->val, TypeCast))
+ if(obj && IsA(obj, TypeCast))
{
- TypeCast *type = (TypeCast *) target->val;
+ TypeCast *type = (TypeCast *) obj;
obj = type->arg;
+
if(!obj)
{
return -1;
}
- } else {
- obj = target->val;
}
if(obj && !IsA(obj, A_Const))
@@ -119,7 +124,7 @@ static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend, RewriteQuer
int dist_def_flag = 0;
InsertStmt *insert = (InsertStmt *) node;
- message->type = node->type;
+ message->type = node->type;
/* insert target table */
@@ -147,7 +152,7 @@ static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend, RewriteQuer
}
/* the source SELECT ? */
- if (insert->selectStmt)
+ if (insert->selectStmt && ((SelectStmt *)insert->selectStmt)->targetList)
{
/* send error message to frontend */
message->r_code = INSERT_SQL_RESTRICTION;
@@ -156,7 +161,8 @@ static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend, RewriteQuer
return;
}
- list_t = (List *) insert->cols;
+ list_t = (List *)(((SelectStmt *)insert->selectStmt)->valuesLists);
+
if (!list_t)
{
/* send error message to frontend */
@@ -169,7 +175,6 @@ static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend, RewriteQuer
/* number of target list */
cell_num = list_t->length;
-
/* Is the target columns ?*/
if (!insert->cols)
{
@@ -187,7 +192,7 @@ static void examInsertStmt(Node *node,POOL_CONNECTION_POOL *backend, RewriteQuer
return;
}
- }
+ }
else
{
List *list_cols = (List *) insert->cols;
[parent: bbe80a770a84]