1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Get rid of pg_class.reltoastidxid.

Treat TOAST index just the same as normal one and get the OID
of TOAST index from pg_index but not pg_class.reltoastidxid.
This change allows us to handle multiple TOAST indexes, and
which is required infrastructure for upcoming
REINDEX CONCURRENTLY feature.

Patch by Michael Paquier, reviewed by Andres Freund and me.
This commit is contained in:
Fujii Masao
2013-07-04 03:24:09 +09:00
parent f71939cd1a
commit 2ef085d0e6
21 changed files with 333 additions and 163 deletions

View File

@@ -103,7 +103,7 @@ static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
bool isvalid);
static void index_update_stats(Relation rel,
bool hasindex, bool isprimary,
Oid reltoastidxid, double reltuples);
double reltuples);
static void IndexCheckExclusion(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo);
@@ -1072,7 +1072,6 @@ index_create(Relation heapRelation,
index_update_stats(heapRelation,
true,
isprimary,
InvalidOid,
-1.0);
/* Make the above update visible */
CommandCounterIncrement();
@@ -1254,7 +1253,6 @@ index_constraint_create(Relation heapRelation,
index_update_stats(heapRelation,
true,
true,
InvalidOid,
-1.0);
/*
@@ -1764,8 +1762,6 @@ FormIndexDatum(IndexInfo *indexInfo,
*
* hasindex: set relhasindex to this value
* isprimary: if true, set relhaspkey true; else no change
* reltoastidxid: if not InvalidOid, set reltoastidxid to this value;
* else no change
* reltuples: if >= 0, set reltuples to this value; else no change
*
* If reltuples >= 0, relpages and relallvisible are also updated (using
@@ -1781,8 +1777,9 @@ FormIndexDatum(IndexInfo *indexInfo,
*/
static void
index_update_stats(Relation rel,
bool hasindex, bool isprimary,
Oid reltoastidxid, double reltuples)
bool hasindex,
bool isprimary,
double reltuples)
{
Oid relid = RelationGetRelid(rel);
Relation pg_class;
@@ -1876,15 +1873,6 @@ index_update_stats(Relation rel,
dirty = true;
}
}
if (OidIsValid(reltoastidxid))
{
Assert(rd_rel->relkind == RELKIND_TOASTVALUE);
if (rd_rel->reltoastidxid != reltoastidxid)
{
rd_rel->reltoastidxid = reltoastidxid;
dirty = true;
}
}
if (reltuples >= 0)
{
@@ -2072,14 +2060,11 @@ index_build(Relation heapRelation,
index_update_stats(heapRelation,
true,
isprimary,
(heapRelation->rd_rel->relkind == RELKIND_TOASTVALUE) ?
RelationGetRelid(indexRelation) : InvalidOid,
stats->heap_tuples);
index_update_stats(indexRelation,
false,
false,
InvalidOid,
stats->index_tuples);
/* Make the updated catalog row versions visible */