pgsql: Teach SPGiST to store nulls and do whole-index scans.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Teach SPGiST to store nulls and do whole-index scans.
Date: 2012-03-11 20:30:30
Message-ID: E1S6pPS-00043n-Sw@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Teach SPGiST to store nulls and do whole-index scans.

This patch fixes the other major compatibility-breaking limitation of
SPGiST, that it didn't store anything for null values of the indexed
column, and so could not support whole-index scans or "x IS NULL"
tests. The approach is to create a wholly separate search tree for
the null entries, and use fixed "allTheSame" insertion and search
rules when processing this tree, instead of calling the index opclass
methods. This way the opclass methods do not need to worry about
dealing with nulls.

Catversion bump is for pg_am updates as well as the change in on-disk
format of SPGiST indexes; there are some tweaks in SPGiST WAL records
as well.

Heavily rewritten version of a patch by Oleg Bartunov and Teodor Sigaev.
(The original also stored nulls separately, but it reused GIN code to do
so; which required undesirable compromises in the on-disk format, and
would likely lead to bugs due to the GIN code being required to work in
two very different contexts.)

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/c6a11b89e48dfb47b305cea405924333dabc20b6

Modified Files
--------------
doc/src/sgml/spgist.sgml | 12 ++
src/backend/access/spgist/README | 32 ++++-
src/backend/access/spgist/spgdoinsert.c | 191 +++++++++++++++++++---------
src/backend/access/spgist/spginsert.c | 48 ++++---
src/backend/access/spgist/spgscan.c | 77 ++++++++---
src/backend/access/spgist/spgutils.c | 76 +++++++----
src/backend/access/spgist/spgvacuum.c | 17 ++-
src/backend/access/spgist/spgxlog.c | 37 ++++--
src/include/access/spgist_private.h | 62 +++++++---
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_am.h | 2 +-
src/test/regress/expected/create_index.out | 112 ++++++++++++++++
src/test/regress/sql/create_index.sql | 32 +++++
13 files changed, 534 insertions(+), 166 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-03-11 20:53:20 pgsql: Fix documented type of t_infomask2.
Previous Message Michael Meskes 2012-03-11 11:26:06 pgsql: Removed redundant "the" from ecpg's docs.