pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: pgsql-bugs@lists.postgresql.org
To: p.otoole@uwyo.edu
Subject: Re: BUG #15534: Operators from public schema in trigger WHEN-clauses are silently allowed despite breaking restores
Date: Sat, 01 Dec 2018 14:40:08 +0000
Message-ID: <87k1ktl49y.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <15534-b06638e5850f55b7@postgresql.org>
References: <15534-b06638e5850f55b7@postgresql.org>

>>>>> "PG" == PG Bug reporting form <noreply@postgresql.org> writes:

 PG> I encountered a problem while trying to copy a few structures to a
 PG> separate database for testing via pg_dump and pg_restore.The issue
 PG> seems to be that operators found in the public schema (which may be
 PG> put there by extensions) are made unavailable during restore [...]

The problem is a bit more subtle:

 PG> CREATE TRIGGER tr BEFORE UPDATE ON t FOR EACH ROW WHEN ( NEW.geom IS
 PG> DISTINCT FROM OLD.geom ) EXECUTE PROCEDURE f();

What's happening here is that IS DISTINCT FROM has a hidden search_path
search in it, that ruleutils doesn't (and can't) handle.

If the clause contained a normal operator not in pg_catalog, it'd get
dumped like this:

CREATE TRIGGER ... WHEN ((old.value OPERATOR(public.<>) new.value)) ...

with an explicit schema for the operator. But IS DISTINCT FROM can't be
used in an OPERATOR clause that way, and the deparse code for
DistinctExpr pays no attention to the schema and assumes it can just
output IS DISTINCT FROM.

Really, IS DISTINCT FROM should get the equality operator from an
opclass rather than assuming it is named "=" and findable via the
search_path. This has been broken since forever, but perhaps this bug
will provide an incentive to get it fixed.

-- 
Andrew (irc:RhodiumToad)




view thread (3+ messages)  latest in thread

Message-ID: <87k1ktl49y.fsf@news-spur.riddles.org.uk>
Permalink:  ../87k1ktl49y.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87k1ktl49y.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, p.otoole@uwyo.edu
  Subject: Re: BUG #15534: Operators from public schema in trigger WHEN-clauses are silently allowed despite breaking restores
  In-Reply-To: <87k1ktl49y.fsf@news-spur.riddles.org.uk>
  References: <15534-b06638e5850f55b7@postgresql.org> <87k1ktl49y.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox