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-08T21:50:25Z
Lists: pgsql-hackers
"Dian M Fay" <dian.m.fay@gmail.com> writes: > On Tue Nov 2, 2021 at 7:10 PM EDT, Tom Lane wrote: >> Actually ... we could make that a lot safer by insisting that the >> other input be a plain Var, which'd necessarily be a column of the >> foreign table. That would still cover most cases of practical >> interest, I think, and it would remove any question of whether >> implicit coercions had snuck in. It's more restrictive than I'd >> really like, but I think it's less likely to cause problems. > I allowed RelabelTypes over Vars to suppress casts as well. It's working > for me so far and the varchar comparison tests are back to passing, sans > casts. Um. I doubt that that's any safer than the v5 patch. As an example, casting between int4 and oid is just a RelabelType, but the comparison semantics change completely (signed vs. unsigned); so there's not a good reason to think this is constraining things more than v5 did. It might be better if you'd further restricted the structure to be only COERCE_IMPLICIT_CAST RelabelTypes, since we don't normally make casts implicit if they significantly change semantics. Also, this'd ensure that the operand printed for the remote server is just a bare Var (cf. deparseRelabelType). But even with that I'm feeling antsy about whether this will allow any semantic surprises. regards, tom lane
Commits
-
postgres_fdw: suppress casts on constants in limited cases.
- f8abb0f5e114 15.0 landed