diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-12-23 20:24:07 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-12-23 20:24:07 -0500 |
commit | cf63c641cae2063a0442d73d49af295301cec61b (patch) | |
tree | d67132751f9ec41c281216cee442a83ce021a014 | |
parent | 8d65da1f01c6a4c84fe9c59aeb6b7e3adf870145 (diff) | |
download | postgresql-cf63c641cae2063a0442d73d49af295301cec61b.tar.gz postgresql-cf63c641cae2063a0442d73d49af295301cec61b.zip |
Fix portability issue in ordered-set patch.
Overly compact coding in makeOrderedSetArgs() led to a platform dependency:
if the compiler chose to execute the subexpressions in the wrong order,
list_length() might get applied to an already-modified List, giving a
value we didn't want. Per buildfarm.
-rw-r--r-- | src/backend/parser/gram.y | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 0249f5cdf35..daa21005f01 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -13385,6 +13385,7 @@ makeOrderedSetArgs(List *directargs, List *orderedargs, core_yyscan_t yyscanner) { FunctionParameter *lastd = (FunctionParameter *) llast(directargs); + int ndirectargs; /* No restriction unless last direct arg is VARIADIC */ if (lastd->mode == FUNC_PARAM_VARIADIC) @@ -13407,8 +13408,11 @@ makeOrderedSetArgs(List *directargs, List *orderedargs, orderedargs = NIL; } + /* don't merge into the next line, as list_concat changes directargs */ + ndirectargs = list_length(directargs); + return list_make2(list_concat(directargs, orderedargs), - makeInteger(list_length(directargs))); + makeInteger(ndirectargs)); } /* insertSelectOptions() |