Rules documentation example

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Rules documentation example
Date: 2019-11-11 18:03:13
Message-ID: CA+renyXZFnmp9PcvX1EVR2dR=XG5e6E-AELr8AHCNZ8RYrpnPw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I'm reading the docs about the Postgres Rule system here:

https://www.postgresql.org/docs/12/rules-views.html

That page says:

> It turns out that the planner will collapse this tree into a two-level query tree: the bottommost SELECT commands will be “pulled up” into the middle SELECT since there's no need to process them separately. But the middle SELECT will remain separate from the top, because it contains aggregate functions. If we pulled those up it would change the behavior of the topmost SELECT, which we don't want.

But I don't see an aggregate function. Is it referring to MIN? But
that is this two-param version defined on the same page. It isn't an
aggregate:

CREATE FUNCTION min(integer, integer) RETURNS integer AS $$
SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END
$$ LANGUAGE SQL STRICT;

Is that an error in the docs, or am I missing something?

Does a non-aggregate function also prevent the subqueries from being
pulled up? Will all levels of that query actually get combined, or
does something else prevent it?

Thanks,
Paul

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-11-11 18:38:49 Re: Rules documentation example
Previous Message Andreas Kretschmer 2019-11-11 15:43:30 Re: security on user for replication