]> granicus.if.org Git - postgresql/commitdiff
deflist_to_tuplestore dumped core on an option with no value.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Sep 2011 15:36:53 +0000 (11:36 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 13 Sep 2011 15:36:53 +0000 (11:36 -0400)
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.

src/backend/foreign/foreign.c

index 4a7b2c30cf3088ed67929a3be20f4843958ec1a8..269a9ad82f52e33488efc4a9cfa77045fb59cb84 100644 (file)
@@ -371,8 +371,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] = nulls[1] = false;
+               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);
        }