From: Bo Peng Date: Thu, 31 Oct 2019 00:11:03 +0000 (+0900) Subject: Fix incorrect query rewrite in replication mode. X-Git-Tag: V3_4_26~1 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=74a6b32faea2fe538f0f9dc966f2f85d0bfaa472;p=pgpool2.git Fix incorrect query rewrite in replication mode. --- diff --git a/src/rewrite/pool_timestamp.c b/src/rewrite/pool_timestamp.c index 2d8045dff..67397c204 100644 --- a/src/rewrite/pool_timestamp.c +++ b/src/rewrite/pool_timestamp.c @@ -753,7 +753,7 @@ rewrite_timestamp(POOL_CONNECTION_POOL *backend, Node *node, /* * CREATE TABLE t1 AS SELECT now(); */ - if (IsA(c_stmt->query, SelectStmt)) + if (IsA(c_stmt->query, SelectStmt) && c_stmt->relkind == OBJECT_TABLE) { /* rewrite params */ raw_expression_tree_walker( @@ -770,16 +770,12 @@ rewrite_timestamp(POOL_CONNECTION_POOL *backend, Node *node, /* * SELECT now() INTO t1; */ - raw_expression_tree_walker( - (Node *) s_stmt, - rewrite_timestamp_walker, (void *) &ctx); - - /* - * WITH ins AS ( INSERT INTO t1 SELECT now()) SELECT; - */ - raw_expression_tree_walker( - (Node *) s_stmt->withClause, - rewrite_timestamp_walker, (void *) &ctx); + if (s_stmt->intoClause) + { + raw_expression_tree_walker( + (Node *) s_stmt, + rewrite_timestamp_walker, (void *) &ctx); + } rewrite = ctx.rewrite; }