Skip to content

Commit cf63c64

Browse files
committed
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.
1 parent 8d65da1 commit cf63c64

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/parser/gram.y

+5-1
Original file line numberDiff line numberDiff line change
@@ -13385,6 +13385,7 @@ makeOrderedSetArgs(List *directargs, List *orderedargs,
1338513385
core_yyscan_t yyscanner)
1338613386
{
1338713387
FunctionParameter *lastd = (FunctionParameter *) llast(directargs);
13388+
int ndirectargs;
1338813389

1338913390
/* No restriction unless last direct arg is VARIADIC */
1339013391
if (lastd->mode == FUNC_PARAM_VARIADIC)
@@ -13407,8 +13408,11 @@ makeOrderedSetArgs(List *directargs, List *orderedargs,
1340713408
orderedargs = NIL;
1340813409
}
1340913410

13411+
/* don't merge into the next line, as list_concat changes directargs */
13412+
ndirectargs = list_length(directargs);
13413+
1341013414
return list_make2(list_concat(directargs, orderedargs),
13411-
makeInteger(list_length(directargs)));
13415+
makeInteger(ndirectargs));
1341213416
}
1341313417

1341413418
/* insertSelectOptions()

0 commit comments

Comments
 (0)