From 5fd386bb31f9a8ed5058093bc3f8937fdde3dbec Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 22 Feb 2013 06:36:09 -0500 Subject: 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. --- contrib/postgres_fdw/postgres_fdw.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'contrib/postgres_fdw/postgres_fdw.c') diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index 0aef00b738d..a3256179f2b 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -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 -- cgit v1.2.3