Skip to content

Commit cac7332

Browse files
committed
deflist_to_tuplestore dumped core on an option with no value.
Make it return NULL for the option_value, instead. Per report from Frank van Vugt. Back-patch to 8.4 where this code was added.
1 parent 4de174d commit cac7332

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/foreign/foreign.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ deflist_to_tuplestore(ReturnSetInfo *rsinfo, List *options)
260260
TupleDesc tupdesc;
261261
Tuplestorestate *tupstore;
262262
Datum values[2];
263-
bool nulls[2] = {0};
263+
bool nulls[2];
264264
MemoryContext per_query_ctx;
265265
MemoryContext oldcontext;
266266

@@ -292,7 +292,17 @@ deflist_to_tuplestore(ReturnSetInfo *rsinfo, List *options)
292292
DefElem *def = lfirst(cell);
293293

294294
values[0] = CStringGetTextDatum(def->defname);
295-
values[1] = CStringGetTextDatum(((Value *) def->arg)->val.str);
295+
nulls[0] = false;
296+
if (def->arg)
297+
{
298+
values[1] = CStringGetTextDatum(((Value *) (def->arg))->val.str);
299+
nulls[1] = false;
300+
}
301+
else
302+
{
303+
values[1] = (Datum) 0;
304+
nulls[1] = true;
305+
}
296306
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
297307
}
298308

0 commit comments

Comments
 (0)