Re: Different results from identical matviews

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Anders Steinlein <anders(at)e5r(dot)no>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Different results from identical matviews
Date: 2020-07-02 16:02:16
Message-ID: CAKFQuwaK2OJLd=RObXANZsE43mNbNoRHCOp1uCknOXFKUeCtBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 2, 2020 at 8:44 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> A plausible explanation for how things got that way is that citext's
> equality operator wasn't in your search_path when you created the original
> matview, but it is in view when you make the new one, allowing that
> equality operator to capture the interpretation of USING. Unfortunately,
> since the reverse-listing of this join is just going to say "USING
> (email)", there's no way to detect from human-readable output that the
> interpretation of the USING clauses is different. (We've contemplated
> introducing not-SQL-standard syntax to allow flagging such cases, but
> haven't pulled the trigger on that.)
>

The citext extension seems to have been installed into the public schema as
well which could introduce the CVE-2018-1058 fix as a potential moving part.

It seems a bit odd though since the textual query does specify "DISTINCT
mails_contacts_opens.email::public.citext" so it does seem to be
search_path induced as the view couldn't exist if the extension was simply
missing not extension specific equality operator were present to match in
front of the default equality operator. But then those casts also make me
question whether the source tables are defined using text instead of citext
in which case the joins using text equality would be expected and their
using citext equality in the new queries potentially suspect.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2020-07-02 16:28:18 Re: survey: psql syntax errors abort my transactions
Previous Message Jeremy Schneider 2020-07-02 15:54:43 survey: psql syntax errors abort my transactions