pgpool2.git / summary / log / commit / refs

commit    b38f68433a873f1e2c514fa822f153b0e87ece65
Author:   pengbo <pengbo@localhost.localdomain>
Date:     Fri Sep 09 04:29:54 2016 +0000

    fix some mistake of COPY query in case of replication mode


src/context/pool_query_context.c | 19 +++++++++++-------- src/protocol/pool_process_query.c | 24 ++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/context/pool_query_context.c b/src/context/pool_query_context.c index 754cbd31c..1962e9119 100644 --- a/src/context/pool_query_context.c +++ b/src/context/pool_query_context.c @@ -1156,15 +1156,18 @@ static POOL_DEST send_to_where(Node *node, char *query) */ else if (IsA(node, CopyStmt)) { - if (((CopyStmt *)node)->is_from) - { - return POOL_PRIMARY; - } - else + if (((CopyStmt *)node)->is_from) { - return (IsA(((CopyStmt *)node)->query, SelectStmt))?POOL_EITHER:POOL_PRIMARY; - } - + return POOL_PRIMARY; + } + else + { + if (((CopyStmt *)node)->query) { + return (IsA(((CopyStmt *)node)->query, SelectStmt))?POOL_EITHER:POOL_PRIMARY; + } else { + return POOL_EITHER; + } + } } /* diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c index 784165823..5a7ba1983 100644 --- a/src/protocol/pool_process_query.c +++ b/src/protocol/pool_process_query.c @@ -1179,8 +1179,28 @@ bool is_select_query(Node *node, char *sql) else if (IsA(node, CopyStmt)) { CopyStmt *copy_stmt = (CopyStmt *)node; - return (copy_stmt->is_from == FALSE && - copy_stmt->filename == NULL); + + if (copy_stmt->is_from) + { + return false; + } + else if (copy_stmt->filename == NULL ) + { + if (copy_stmt->query == NULL) + { + return true; + } + else if (copy_stmt->query && IsA(copy_stmt->query, SelectStmt)) + { + return true; + } + else + { + return false; + } + } else { + return false; + } } else if (IsA(node, ExplainStmt)) { [parent: 233f5bce0088]