Re: [PATCH] postgres_fdw: suppress explicit casts in text:text comparisons (was: column option to override foreign types)

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Dian M Fay" <dian.m.fay@gmail.com>
Cc: "David Steele" <david@pgmasters.net>, "Georgios Kokolatos" <gkokolatos@protonmail.com>, "PostgreSQL Developers" <pgsql-hackers@lists.postgresql.org>
Date: 2021-11-11T20:36:53Z
Lists: pgsql-hackers

Attachments

"Dian M Fay" <dian.m.fay@gmail.com> writes:
> I've split the suppression for RelabelTypes with implicit cast check
> into a second patch over the core v7 change. As far as testing goes, \dC
> lists implicit casts, but most of those I've tried seem to wind up
> deparsing as Vars. I've been able to manifest RelabelTypes with varchar,
> cidr, and remote char to local varchar, but that's about it. Any ideas
> for validating it further, off the top of your head?

I thought about this some more and realized exactly why I wanted to
restrict the change to cases where the other side is a plain foreign Var:
that way, if anything surprising happens, we can blame it directly on the
user having declared a local column with a different type from the
remote column.

That being the case, I took a closer look at deparseVar and realized that
we can't simply check "IsA(node, Var)": some Vars in the expression can
belong to local tables.  We need to verify that the Var is one that will
print as a remote column reference.

So that leads me to v8, attached.  I think we are getting there.

			regards, tom lane

Commits

  1. postgres_fdw: suppress casts on constants in limited cases.