Commit a7e383d2 authored by Tom Lane's avatar Tom Lane

Repair badly broken estimation of output buffer size in lquery_out().

parent f758097c
...@@ -498,22 +498,21 @@ lquery_out(PG_FUNCTION_ARGS) ...@@ -498,22 +498,21 @@ lquery_out(PG_FUNCTION_ARGS)
*ptr; *ptr;
int i, int i,
j, j,
totallen = 0; totallen = 1;
lquery_level *curqlevel; lquery_level *curqlevel;
lquery_variant *curtlevel; lquery_variant *curtlevel;
curqlevel = LQUERY_FIRST(in); curqlevel = LQUERY_FIRST(in);
for (i = 0; i < in->numlevel; i++) for (i = 0; i < in->numlevel; i++)
{ {
totallen++;
if (curqlevel->numvar) if (curqlevel->numvar)
totallen = (curqlevel->numvar * 4) + 1 + curqlevel->totallen; totallen += 1 + (curqlevel->numvar * 4) + curqlevel->totallen;
else else
totallen = 2 * 11 + 4; totallen += 2 * 11 + 4;
totallen++;
curqlevel = LQL_NEXT(curqlevel); curqlevel = LQL_NEXT(curqlevel);
} }
ptr = buf = (char *) palloc(totallen); ptr = buf = (char *) palloc(totallen);
curqlevel = LQUERY_FIRST(in); curqlevel = LQUERY_FIRST(in);
for (i = 0; i < in->numlevel; i++) for (i = 0; i < in->numlevel; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment