Re: FIX : teach expression walker about RestrictInfo

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FIX : teach expression walker about RestrictInfo
Date: 2015-04-28 21:39:45
Message-ID: 553FFE21.8050401@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 04/28/15 21:50, Tom Lane wrote:
> Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> writes:
>> the attached trivial patch adds handling of RestrictInfo nodes into
>> expression_tree_walker().
>
> RestrictInfo is not a general expression node and support for it has
> been deliberately omitted from expression_tree_walker(). So I think
> what you are proposing is a bad idea and probably a band-aid for some
> other bad idea.
>
>> This is needed for example when calling
>> pull_varnos or (or other functions using the expression walker) in
>> clausesel.c, for example. An example of a query causing errors with
>> pull_varnos is
>
>> select * from t where (a >= 10 and a <= 20) or (b >= 15 and b <= 20);
>
> Really?
>
> regression=# create table t (a int, b int);
> CREATE TABLE
> regression=# select * from t where (a >= 10 and a <= 20) or (b >= 15 and b <= 20);
> a | b
> ---+---
> (0 rows)

That's not what I said, though. I said that calling pull_varnos() causes
the issue - apparently that does not happen in master, but I ran into
that when hacking on a patch.

For example try adding this

Relids tmp = pull_varnos(clause);
elog(WARNING, "count = %d", bms_num_members(tmp));

into the or_clause branch in clause_selectivity(), and then running the
query will give you this:

db=# select * from t where (a >= 10 and a <= 20) or (b >= 15);
ERROR: unrecognized node type: 524

But as I said - maybe calls to pull_varnos are not supposed to happen in
this part of the code, for some reason, and it really is a bug in my patch.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2015-04-28 23:14:04 Re: shared_libperl, shared_libpython
Previous Message Bruce Momjian 2015-04-28 21:35:40 Re: tablespaces inside $PGDATA considered harmful