]> granicus.if.org Git - postgresql/commitdiff
Call FDW validator functions even when the options list is empty.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 5 Jul 2011 22:21:12 +0000 (18:21 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 5 Jul 2011 22:21:28 +0000 (18:21 -0400)
This is useful since a validator might want to require certain options
to be provided.  The passed array is an empty text array in this case.

Per suggestion by Laurenz Albe, though this is not quite his patch.

src/backend/commands/foreigncmds.c

index 21d52e06ba035fa095ce029e0fc5f49970c2d3ff..643ba91bfe1c50f048cf6f3364fb5f1e6dee8895 100644 (file)
@@ -165,8 +165,18 @@ transformGenericOptions(Oid catalogId,
 
        result = optionListToArray(resultOptions);
 
-       if (OidIsValid(fdwvalidator) && DatumGetPointer(result) != NULL)
-               OidFunctionCall2(fdwvalidator, result, ObjectIdGetDatum(catalogId));
+       if (OidIsValid(fdwvalidator))
+       {
+               Datum   valarg = result;
+
+               /*
+                * Pass a null options list as an empty array, so that validators
+                * don't have to be declared non-strict to handle the case.
+                */
+               if (DatumGetPointer(valarg) == NULL)
+                       valarg = PointerGetDatum(construct_empty_array(TEXTOID));
+               OidFunctionCall2(fdwvalidator, valarg, ObjectIdGetDatum(catalogId));
+       }
 
        return result;
 }