summaryrefslogtreecommitdiff
path: root/src/parser/outfuncs.c
diff options
context:
space:
mode:
authorTatsuo Ishii2022-12-20 10:06:22 +0000
committerTatsuo Ishii2022-12-20 10:06:22 +0000
commita6c62f6bd82d148cdf45420eae91a0739f93f178 (patch)
tree7bbcfc54de9b9ce2e0ed4bd30313130d37203ef9 /src/parser/outfuncs.c
parent8ca4aa132c2909b9910844847174c92ff66085ca (diff)
Fix time stamp rewrite bug.
In native replication/snapshot isolation mode, any write query including timestamp/date/time data are rewritten so that all PostgreSQL servers accept same timestamp etc. value. From 4.4 outfuncs module which is used to generate rewritten query was broken for boolean data. In a parse tree constant data is represented as "A_Const". 4.4 updated the module by using PostgreSQL 15's outfuncs module. Starting from PostgreSQL 15 A_Const handles more data type including boolean. Unfortunately the pgpool's outfuncs module did not adopt the change. As a result boolean constant was ignored and turned into empty string in the rewritten query string, which caused syntax errors. This commit fixes the issue. Also modify _outA_Const() so that it uses _out* functions to handle other data types to save a few lines of code. Per report from Michiel van Leening. Discussion: at: https://www.pgpool.net/pipermail/pgpool-general/2022-December/008581.html Back-patch to: 4.4.
Diffstat (limited to 'src/parser/outfuncs.c')
-rw-r--r--src/parser/outfuncs.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/parser/outfuncs.c b/src/parser/outfuncs.c
index 2ed60b58d..3e570bec4 100644
--- a/src/parser/outfuncs.c
+++ b/src/parser/outfuncs.c
@@ -1939,7 +1939,6 @@ _outParamRef(StringInfo str, ParamRef *node)
static void
_outA_Const(StringInfo str, A_Const *node)
{
- char buf[16];
char *p;
if (node->isnull)
@@ -1951,12 +1950,11 @@ _outA_Const(StringInfo str, A_Const *node)
switch (nodeTag(&node->val))
{
case T_Integer:
- sprintf(buf, "%d", node->val.ival.ival);
- appendStringInfoString(str, buf);
+ _outInteger(str, &node->val.ival);
break;
case T_Float:
- appendStringInfoString(str, node->val.fval.fval);
+ _outFloat(str, &node->val.fval);
break;
case T_String:
@@ -1968,10 +1966,15 @@ _outA_Const(StringInfo str, A_Const *node)
break;
case T_BitString:
- appendStringInfoString(str, node->val.bsval.bsval);
+ _outBitString(str, &node->val.bsval);
+ break;
+
+ case T_Boolean:
+ _outBoolean(str, &node->val.boolval);
break;
default:
+ elog(ERROR, "unrecognized A_Const kind: %d", nodeTag(&node->val));
break;
}
}