aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/postgres_fdw.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-02-22 06:36:09 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-02-22 06:36:54 -0500
commit5fd386bb31f9a8ed5058093bc3f8937fdde3dbec (patch)
tree09ef42133484a44d7625f733c5c314360b5efa9a /contrib/postgres_fdw/postgres_fdw.c
parent6c4f6664b201bea77eb6e3f813559e3911a5ef35 (diff)
downloadpostgresql-5fd386bb31f9a8ed5058093bc3f8937fdde3dbec.tar.gz
postgresql-5fd386bb31f9a8ed5058093bc3f8937fdde3dbec.zip
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.
Diffstat (limited to 'contrib/postgres_fdw/postgres_fdw.c')
-rw-r--r--contrib/postgres_fdw/postgres_fdw.c15
1 files changed, 14 insertions, 1 deletions
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
@@ -902,10 +902,23 @@ create_cursor(ForeignScanState *node)
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