aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/dbsize.c
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2013-07-04 03:24:09 +0900
committerFujii Masao <fujii@postgresql.org>2013-07-04 03:24:09 +0900
commit2ef085d0e6960f5087c97266a7211d37ddaa9f68 (patch)
tree7edac95cbc3bbe0aea721e95e8d4804486a7d0ea /src/backend/utils/adt/dbsize.c
parentf71939cd1ac765ba618115f40de4d9c47955a9ef (diff)
downloadpostgresql-2ef085d0e6960f5087c97266a7211d37ddaa9f68.tar.gz
postgresql-2ef085d0e6960f5087c97266a7211d37ddaa9f68.zip
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.
Diffstat (limited to 'src/backend/utils/adt/dbsize.c')
-rw-r--r--src/backend/utils/adt/dbsize.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index 5ddeffe4820..34482abee3e 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -332,7 +332,7 @@ pg_relation_size(PG_FUNCTION_ARGS)
}
/*
- * Calculate total on-disk size of a TOAST relation, including its index.
+ * Calculate total on-disk size of a TOAST relation, including its indexes.
* Must not be applied to non-TOAST relations.
*/
static int64
@@ -340,8 +340,9 @@ calculate_toast_table_size(Oid toastrelid)
{
int64 size = 0;
Relation toastRel;
- Relation toastIdxRel;
ForkNumber forkNum;
+ ListCell *lc;
+ List *indexlist;
toastRel = relation_open(toastrelid, AccessShareLock);
@@ -351,12 +352,21 @@ calculate_toast_table_size(Oid toastrelid)
toastRel->rd_backend, forkNum);
/* toast index size, including FSM and VM size */
- toastIdxRel = relation_open(toastRel->rd_rel->reltoastidxid, AccessShareLock);
- for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
- size += calculate_relation_size(&(toastIdxRel->rd_node),
- toastIdxRel->rd_backend, forkNum);
+ indexlist = RelationGetIndexList(toastRel);
- relation_close(toastIdxRel, AccessShareLock);
+ /* Size is calculated using all the indexes available */
+ foreach(lc, indexlist)
+ {
+ Relation toastIdxRel;
+ toastIdxRel = relation_open(lfirst_oid(lc),
+ AccessShareLock);
+ for (forkNum = 0; forkNum <= MAX_FORKNUM; forkNum++)
+ size += calculate_relation_size(&(toastIdxRel->rd_node),
+ toastIdxRel->rd_backend, forkNum);
+
+ relation_close(toastIdxRel, AccessShareLock);
+ }
+ list_free(indexlist);
relation_close(toastRel, AccessShareLock);
return size;