From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Erik Rijkers <er(at)xs4all(dot)nl> |
Cc: | Thom Brown <thom(at)linux(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Minmax indexes |
Date: | 2013-09-17 21:59:55 |
Message-ID: | 20130917215955.GJ6056@eldon.alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Erik Rijkers wrote:
> On Tue, September 17, 2013 23:03, Alvaro Herrera wrote:
>
> > [minmax-1.patch. + minmax-2-incr.patch. (and initdb)]
>
>
> The patches apply and compile OK.
>
> I've not yet really tested; I just wanted to mention that make check gives the following differences:
Oops, I forgot to update the expected file. I had to comment on this
when submitting minmax-2-incr.patch and forgot. First, those extra five
operators are supposed to be there; expected file needs an update. As
for this:
> --- 1277,1288 ----
> WHERE am.amname <> 'btree' AND am.amname <> 'gist' AND am.amname <> 'gin'
> GROUP BY amname, amsupport, opcname, amprocfamily
> HAVING count(*) != amsupport OR amprocfamily IS NULL;
> ! amname | opcname | count
> ! --------+-------------+-------
> ! minmax | int4_ops | 1
> ! minmax | text_ops | 1
> ! minmax | numeric_ops | 1
> ! (3 rows)
I think the problem is that the query is wrong. This is the complete query:
SELECT amname, opcname, count(*)
FROM pg_am am JOIN pg_opclass op ON opcmethod = am.oid
LEFT JOIN pg_amproc p ON amprocfamily = opcfamily AND
amproclefttype = amprocrighttype AND amproclefttype = opcintype
WHERE am.amname <> 'btree' AND am.amname <> 'gist' AND am.amname <> 'gin'
GROUP BY amname, amsupport, opcname, amprocfamily
HAVING count(*) != amsupport OR amprocfamily IS NULL;
I should be, instead, this:
SELECT amname, opcname, count(*)
FROM pg_am am JOIN pg_opclass op ON opcmethod = am.oid
LEFT JOIN pg_amproc p ON amprocfamily = opcfamily AND
amproclefttype = amprocrighttype AND amproclefttype = opcintype
WHERE am.amname <> 'btree' AND am.amname <> 'gist' AND am.amname <> 'gin'
GROUP BY amname, amsupport, opcname, amprocfamily
HAVING count(*) != amsupport AND (amprocfamily IS NOT NULL);
This query is supposed to check that there are no opclasses with
mismatching number of support procedures; but if the left join returns a
null-extended row for pg_amproc, that means there is no support proc,
yet count(*) will return 1. So count(*) will not match amsupport, and
the row is supposed to be excluded by the amprocfamily IS NULL clause in
HAVING.
Both queries return empty in HEAD, but only the second one correctly
returns empty with the patch applied.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Tiikkaja | 2013-09-17 22:09:34 | Re: Assertions in PL/PgSQL |
Previous Message | Alvaro Herrera | 2013-09-17 21:52:24 | Re: Minmax indexes |