Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2e56fa8

Browse files
committed
Call FDW validator functions even when the options list is empty.
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.
1 parent 9a0bdc8 commit 2e56fa8

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/backend/commands/foreigncmds.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,18 @@ transformGenericOptions(Oid catalogId,
165165

166166
result = optionListToArray(resultOptions);
167167

168-
if (OidIsValid(fdwvalidator) && DatumGetPointer(result) != NULL)
169-
OidFunctionCall2(fdwvalidator, result, ObjectIdGetDatum(catalogId));
168+
if (OidIsValid(fdwvalidator))
169+
{
170+
Datum valarg = result;
171+
172+
/*
173+
* Pass a null options list as an empty array, so that validators
174+
* don't have to be declared non-strict to handle the case.
175+
*/
176+
if (DatumGetPointer(valarg) == NULL)
177+
valarg = PointerGetDatum(construct_empty_array(TEXTOID));
178+
OidFunctionCall2(fdwvalidator, valarg, ObjectIdGetDatum(catalogId));
179+
}
170180

171181
return result;
172182
}

0 commit comments

Comments
 (0)