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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Dian M Fay" <dian(dot)m(dot)fay(at)gmail(dot)com>
Cc: "David Steele" <david(at)pgmasters(dot)net>, "Georgios Kokolatos" <gkokolatos(at)protonmail(dot)com>, "PostgreSQL Developers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] postgres_fdw: suppress explicit casts in text:text comparisons (was: column option to override foreign types)
Date: 2021-11-08 21:50:25
Message-ID: 1001757.1636408225@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Dian M Fay" <dian(dot)m(dot)fay(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua Brindle 2021-11-08 22:15:27 Re: [PATCH v2] use has_privs_for_role for predefined roles
Previous Message Robert Haas 2021-11-08 21:41:22 Re: refactoring basebackup.c