aboutsummaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/deparse.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/deparse.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/deparse.c')
-rw-r--r--contrib/postgres_fdw/deparse.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index f005e0f26fb..1f4b2449be7 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -331,12 +331,10 @@ foreign_expr_walker(Node *node, foreign_expr_cxt *context)
* function or type defined in the information_schema.
*
* Our constraints for dealing with types are tighter than they are for
- * functions or operators: we want to accept only types that are in pg_catalog
- * (else format_type might incorrectly fail to schema-qualify their names),
- * and we want to be sure that the remote server will use the same OID as
- * we do (since we must transmit a numeric type OID when passing a value of
- * the type as a query parameter). Both of these are reasons to reject
- * objects created post-bootstrap.
+ * functions or operators: we want to accept only types that are in pg_catalog,
+ * else format_type might incorrectly fail to schema-qualify their names.
+ * (This could be fixed with some changes to format_type, but for now there's
+ * no need.) Thus we must exclude information_schema types.
*
* XXX there is a problem with this, which is that the set of built-in
* objects expands over time. Something that is built-in to us might not
@@ -794,12 +792,20 @@ deparseConst(StringInfo buf, Const *node, PlannerInfo *root)
* We don't need to renumber the parameter ID, because the executor functions
* in postgres_fdw.c preserve the numbering of PARAM_EXTERN Params.
* (This might change soon.)
+ *
+ * Note: we label the Param's type explicitly rather than relying on
+ * transmitting a numeric type OID in PQexecParams(). This allows us to
+ * avoid assuming that types have the same OIDs on the remote side as they
+ * do locally --- they need only have the same names.
*/
static void
deparseParam(StringInfo buf, Param *node, PlannerInfo *root)
{
Assert(node->paramkind == PARAM_EXTERN);
appendStringInfo(buf, "$%d", node->paramid);
+ appendStringInfo(buf, "::%s",
+ format_type_with_typemod(node->paramtype,
+ node->paramtypmod));
}
/*