From: Tom Lane Date: Tue, 13 Sep 2011 15:37:03 +0000 (-0400) Subject: deflist_to_tuplestore dumped core on an option with no value. X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=5d68fe14fcc6012cd9e7178422d37cb88cb17196;p=users%2Fc2main%2Fpostgres.git 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. --- diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c index f32a296f5b..2555afb782 100644 --- a/src/backend/foreign/foreign.c +++ b/src/backend/foreign/foreign.c @@ -270,7 +270,7 @@ deflist_to_tuplestore(ReturnSetInfo *rsinfo, List *options) TupleDesc tupdesc; Tuplestorestate *tupstore; Datum values[2]; - bool nulls[2] = {0}; + bool nulls[2]; MemoryContext per_query_ctx; MemoryContext oldcontext; @@ -302,7 +302,17 @@ deflist_to_tuplestore(ReturnSetInfo *rsinfo, List *options) DefElem *def = lfirst(cell); values[0] = CStringGetTextDatum(def->defname); - values[1] = CStringGetTextDatum(((Value *) def->arg)->val.str); + nulls[0] = false; + if (def->arg) + { + values[1] = CStringGetTextDatum(((Value *) (def->arg))->val.str); + nulls[1] = false; + } + else + { + values[1] = (Datum) 0; + nulls[1] = true; + } tuplestore_putvalues(tupstore, tupdesc, values, nulls); }