Skip to content

Commit 7e2f906

Browse files
committed
Remove pg_am.amindexnulls.
The only use we have had for amindexnulls is in determining whether an index is safe to cluster on; but since the addition of the amclusterable flag, that usage is pretty redundant. In passing, clean up assorted sloppiness from the last patch that touched pg_am.h: Natts_pg_am was wrong, and ambuildempty was not documented.
1 parent 56a5747 commit 7e2f906

File tree

5 files changed

+35
-76
lines changed

5 files changed

+35
-76
lines changed

doc/src/sgml/catalogs.sgml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,6 @@
469469
for the first index column?</entry>
470470
</row>
471471

472-
<row>
473-
<entry><structfield>amindexnulls</structfield></entry>
474-
<entry><type>bool</type></entry>
475-
<entry></entry>
476-
<entry>Does the access method support null index entries?</entry>
477-
</row>
478-
479472
<row>
480473
<entry><structfield>amsearchnulls</structfield></entry>
481474
<entry><type>bool</type></entry>
@@ -567,6 +560,13 @@
567560
<entry><quote>Build new index</quote> function</entry>
568561
</row>
569562

563+
<row>
564+
<entry><structfield>ambuildempty</structfield></entry>
565+
<entry><type>regproc</type></entry>
566+
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
567+
<entry><quote>Build empty index</quote> function</entry>
568+
</row>
569+
570570
<row>
571571
<entry><structfield>ambulkdelete</structfield></entry>
572572
<entry><type>regproc</type></entry>

doc/src/sgml/indexam.sgml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,15 @@
105105
where no indexable restriction clause is given for the first index column.
106106
When <structfield>amcanmulticol</structfield> is false,
107107
<structfield>amoptionalkey</structfield> essentially says whether the
108-
access method allows full-index scans without any restriction clause.
108+
access method supports full-index scans without any restriction clause.
109109
Access methods that support multiple index columns <emphasis>must</>
110110
support scans that omit restrictions on any or all of the columns after
111111
the first; however they are permitted to require some restriction to
112112
appear for the first index column, and this is signaled by setting
113113
<structfield>amoptionalkey</structfield> false.
114-
<structfield>amindexnulls</structfield> asserts that index entries are
115-
created for NULL key values. Since most indexable operators are
114+
One reason that an index AM might set
115+
<structfield>amoptionalkey</structfield> false is if it doesn't index
116+
NULLs. Since most indexable operators are
116117
strict and hence cannot return TRUE for NULL inputs,
117118
it is at first sight attractive to not store index entries for null values:
118119
they could never be returned by an index scan anyway. However, this
@@ -129,10 +130,7 @@
129130
used to scan for rows with <literal>a = 4</literal>, which is wrong if the
130131
index omits rows where <literal>b</> is null.
131132
It is, however, OK to omit rows where the first indexed column is null.
132-
Thus, <structfield>amindexnulls</structfield> should be set true only if the
133-
index access method indexes all rows, including arbitrary combinations of
134-
null values. An index access method that sets
135-
<structfield>amindexnulls</structfield> may also set
133+
An index access method that does index nulls may also set
136134
<structfield>amsearchnulls</structfield>, indicating that it supports
137135
<literal>IS NULL</> and <literal>IS NOT NULL</> clauses as search
138136
conditions.

src/backend/commands/cluster.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -436,43 +436,6 @@ check_index_is_clusterable(Relation OldHeap, Oid indexOid, bool recheck, LOCKMOD
436436
errmsg("cannot cluster on partial index \"%s\"",
437437
RelationGetRelationName(OldIndex))));
438438

439-
if (!OldIndex->rd_am->amindexnulls)
440-
{
441-
AttrNumber colno;
442-
443-
/*
444-
* If the AM doesn't index nulls, then it's a partial index unless we
445-
* can prove all the rows are non-null. Note we only need look at the
446-
* first column; multicolumn-capable AMs are *required* to index nulls
447-
* in columns after the first.
448-
*/
449-
colno = OldIndex->rd_index->indkey.values[0];
450-
if (colno > 0)
451-
{
452-
/* ordinary user attribute */
453-
if (!OldHeap->rd_att->attrs[colno - 1]->attnotnull)
454-
ereport(ERROR,
455-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
456-
errmsg("cannot cluster on index \"%s\" because access method does not handle null values",
457-
RelationGetRelationName(OldIndex)),
458-
recheck
459-
? errhint("You might be able to work around this by marking column \"%s\" NOT NULL, or use ALTER TABLE ... SET WITHOUT CLUSTER to remove the cluster specification from the table.",
460-
NameStr(OldHeap->rd_att->attrs[colno - 1]->attname))
461-
: errhint("You might be able to work around this by marking column \"%s\" NOT NULL.",
462-
NameStr(OldHeap->rd_att->attrs[colno - 1]->attname))));
463-
}
464-
else if (colno < 0)
465-
{
466-
/* system column --- okay, always non-null */
467-
}
468-
else
469-
/* index expression, lose... */
470-
ereport(ERROR,
471-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
472-
errmsg("cannot cluster on expressional index \"%s\" because its index access method does not handle null values",
473-
RelationGetRelationName(OldIndex))));
474-
}
475-
476439
/*
477440
* Disallow if index is left over from a failed CREATE INDEX CONCURRENTLY;
478441
* it might well not contain entries for every heap row, or might not even

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201101071
56+
#define CATALOG_VERSION_NO 201101081
5757

5858
#endif

src/include/catalog/pg_am.h

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ CATALOG(pg_am,2601)
4646
bool amcanunique; /* does AM support UNIQUE indexes? */
4747
bool amcanmulticol; /* does AM support multi-column indexes? */
4848
bool amoptionalkey; /* can query omit key for the first column? */
49-
bool amindexnulls; /* does AM support NULL index entries? */
5049
bool amsearchnulls; /* can AM search for NULL/NOT NULL entries? */
5150
bool amstorage; /* can storage type differ from column type? */
5251
bool amclusterable; /* does AM support cluster command? */
@@ -88,41 +87,40 @@ typedef FormData_pg_am *Form_pg_am;
8887
#define Anum_pg_am_amcanunique 7
8988
#define Anum_pg_am_amcanmulticol 8
9089
#define Anum_pg_am_amoptionalkey 9
91-
#define Anum_pg_am_amindexnulls 10
92-
#define Anum_pg_am_amsearchnulls 11
93-
#define Anum_pg_am_amstorage 12
94-
#define Anum_pg_am_amclusterable 13
95-
#define Anum_pg_am_amkeytype 14
96-
#define Anum_pg_am_aminsert 15
97-
#define Anum_pg_am_ambeginscan 16
98-
#define Anum_pg_am_amgettuple 17
99-
#define Anum_pg_am_amgetbitmap 18
100-
#define Anum_pg_am_amrescan 19
101-
#define Anum_pg_am_amendscan 20
102-
#define Anum_pg_am_ammarkpos 21
103-
#define Anum_pg_am_amrestrpos 22
104-
#define Anum_pg_am_ambuild 23
105-
#define Anum_pg_am_ambuildempty 24
106-
#define Anum_pg_am_ambulkdelete 25
107-
#define Anum_pg_am_amvacuumcleanup 26
108-
#define Anum_pg_am_amcostestimate 27
109-
#define Anum_pg_am_amoptions 28
90+
#define Anum_pg_am_amsearchnulls 10
91+
#define Anum_pg_am_amstorage 11
92+
#define Anum_pg_am_amclusterable 12
93+
#define Anum_pg_am_amkeytype 13
94+
#define Anum_pg_am_aminsert 14
95+
#define Anum_pg_am_ambeginscan 15
96+
#define Anum_pg_am_amgettuple 16
97+
#define Anum_pg_am_amgetbitmap 17
98+
#define Anum_pg_am_amrescan 18
99+
#define Anum_pg_am_amendscan 19
100+
#define Anum_pg_am_ammarkpos 20
101+
#define Anum_pg_am_amrestrpos 21
102+
#define Anum_pg_am_ambuild 22
103+
#define Anum_pg_am_ambuildempty 23
104+
#define Anum_pg_am_ambulkdelete 24
105+
#define Anum_pg_am_amvacuumcleanup 25
106+
#define Anum_pg_am_amcostestimate 26
107+
#define Anum_pg_am_amoptions 27
110108

111109
/* ----------------
112110
* initial contents of pg_am
113111
* ----------------
114112
*/
115113

116-
DATA(insert OID = 403 ( btree 5 1 t f t t t t t t f t 0 btinsert btbeginscan btgettuple btgetbitmap btrescan btendscan btmarkpos btrestrpos btbuild btbuildempty btbulkdelete btvacuumcleanup btcostestimate btoptions ));
114+
DATA(insert OID = 403 ( btree 5 1 t f t t t t t f t 0 btinsert btbeginscan btgettuple btgetbitmap btrescan btendscan btmarkpos btrestrpos btbuild btbuildempty btbulkdelete btvacuumcleanup btcostestimate btoptions ));
117115
DESCR("b-tree index access method");
118116
#define BTREE_AM_OID 403
119-
DATA(insert OID = 405 ( hash 1 1 f f t f f f f f f f 23 hashinsert hashbeginscan hashgettuple hashgetbitmap hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbuildempty hashbulkdelete hashvacuumcleanup hashcostestimate hashoptions ));
117+
DATA(insert OID = 405 ( hash 1 1 f f t f f f f f f 23 hashinsert hashbeginscan hashgettuple hashgetbitmap hashrescan hashendscan hashmarkpos hashrestrpos hashbuild hashbuildempty hashbulkdelete hashvacuumcleanup hashcostestimate hashoptions ));
120118
DESCR("hash index access method");
121119
#define HASH_AM_OID 405
122-
DATA(insert OID = 783 ( gist 0 8 f t f f t t t t t t 0 gistinsert gistbeginscan gistgettuple gistgetbitmap gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbuildempty gistbulkdelete gistvacuumcleanup gistcostestimate gistoptions ));
120+
DATA(insert OID = 783 ( gist 0 8 f t f f t t t t t 0 gistinsert gistbeginscan gistgettuple gistgetbitmap gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbuildempty gistbulkdelete gistvacuumcleanup gistcostestimate gistoptions ));
123121
DESCR("GiST index access method");
124122
#define GIST_AM_OID 783
125-
DATA(insert OID = 2742 ( gin 0 5 f f f f t t f f t f 0 gininsert ginbeginscan - gingetbitmap ginrescan ginendscan ginmarkpos ginrestrpos ginbuild ginbuildempty ginbulkdelete ginvacuumcleanup gincostestimate ginoptions ));
123+
DATA(insert OID = 2742 ( gin 0 5 f f f f t t f t f 0 gininsert ginbeginscan - gingetbitmap ginrescan ginendscan ginmarkpos ginrestrpos ginbuild ginbuildempty ginbulkdelete ginvacuumcleanup gincostestimate ginoptions ));
126124
DESCR("GIN index access method");
127125
#define GIN_AM_OID 2742
128126

0 commit comments

Comments
 (0)