1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-11 20:28:21 +03:00

Get rid of postgres_fdw's assumption that remote type OIDs match ours.

The only place we depended on that was in sending numeric type OIDs in
PQexecParams; but we can replace that usage with explicitly casting
each Param symbol in the query string, so that the types are specified
to the remote by name not OID.  This makes no immediate difference but
will be essential if we ever hope to support use of non-builtin types.
This commit is contained in:
Tom Lane
2013-02-22 06:36:09 -05:00
parent 6c4f6664b2
commit 5fd386bb31
3 changed files with 32 additions and 13 deletions

View File

@ -901,11 +901,24 @@ create_cursor(ForeignScanState *node)
if (!OidIsValid(prm->ptype) && params->paramFetch != NULL)
params->paramFetch(params, paramno);
/*
* Force the remote server to infer a type for this parameter.
* Since we explicitly cast every parameter (see deparse.c), the
* "inference" is trivial and will produce the desired result.
* This allows us to avoid assuming that the remote server has the
* same OIDs we do for the parameters' types.
*
* We'd not need to pass a type array to PQexecParams at all,
* except that there may be unused holes in the array, which
* will have to be filled with something or the remote server will
* complain. We arbitrarily set them to INT4OID earlier.
*/
types[paramno - 1] = InvalidOid;
/*
* Get string representation of each parameter value by invoking
* type-specific output function, unless the value is null.
*/
types[paramno - 1] = prm->ptype;
if (prm->isnull)
values[paramno - 1] = NULL;
else