From 0138d9f0463cf36c9460a7d8d1eb8fe37a024cf0 Mon Sep 17 00:00:00 2001 From: Andrey Sokolov Date: Fri, 1 Nov 2024 14:02:47 +0300 Subject: [PATCH] Remove storage manager for AO tables --- src/backend/access/aocs/aocsam_handler.c | 10 ++++---- .../access/appendonly/appendonlyam_handler.c | 10 ++++---- src/backend/catalog/storage.c | 3 +-- src/backend/commands/tablecmds.c | 2 +- src/backend/storage/smgr/smgr.c | 25 +------------------ src/include/storage/smgr.h | 3 +-- src/include/utils/rel.h | 2 +- 7 files changed, 15 insertions(+), 40 deletions(-) diff --git a/src/backend/access/aocs/aocsam_handler.c b/src/backend/access/aocs/aocsam_handler.c index 00149a8eba3a..bfef1c59d4b9 100644 --- a/src/backend/access/aocs/aocsam_handler.c +++ b/src/backend/access/aocs/aocsam_handler.c @@ -1292,7 +1292,7 @@ aoco_relation_set_new_filenode(Relation rel, * * Segment files will be created when / if needed. */ - srel = RelationCreateStorage(*newrnode, persistence, SMGR_AO); + srel = RelationCreateStorage(*newrnode, persistence, SMGR_MD); /* * If required, set up an init fork for an unlogged table so that it can @@ -1309,7 +1309,7 @@ aoco_relation_set_new_filenode(Relation rel, rel->rd_rel->relkind == RELKIND_MATVIEW || rel->rd_rel->relkind == RELKIND_TOASTVALUE); smgrcreate(srel, INIT_FORKNUM, false); - log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_AO); + log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_MD); smgrimmedsync(srel, INIT_FORKNUM); } @@ -1360,7 +1360,7 @@ aoco_relation_copy_data(Relation rel, const RelFileNode *newrnode) * Use the "AO-specific" (non-shared buffers backed storage) SMGR * implementation */ - dstrel = smgropen(*newrnode, rel->rd_backend, SMGR_AO); + dstrel = smgropen(*newrnode, rel->rd_backend, SMGR_MD); RelationOpenSmgr(rel); /* @@ -1370,7 +1370,7 @@ aoco_relation_copy_data(Relation rel, const RelFileNode *newrnode) * NOTE: any conflict in relfilenode value will be caught in * RelationCreateStorage(). */ - RelationCreateStorage(*newrnode, rel->rd_rel->relpersistence, SMGR_AO); + RelationCreateStorage(*newrnode, rel->rd_rel->relpersistence, SMGR_MD); copy_append_only_data(rel->rd_node, *newrnode, rel->rd_backend, rel->rd_rel->relpersistence); @@ -1389,7 +1389,7 @@ aoco_relation_copy_data(Relation rel, const RelFileNode *newrnode) */ smgrcreate(dstrel, INIT_FORKNUM, false); - log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_AO); + log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_MD); } /* drop old relation, and close new one */ diff --git a/src/backend/access/appendonly/appendonlyam_handler.c b/src/backend/access/appendonly/appendonlyam_handler.c index f3b54cb71b51..961a13e2ee5d 100644 --- a/src/backend/access/appendonly/appendonlyam_handler.c +++ b/src/backend/access/appendonly/appendonlyam_handler.c @@ -1065,7 +1065,7 @@ appendonly_relation_set_new_filenode(Relation rel, * * Segment files will be created when / if needed. */ - srel = RelationCreateStorage(*newrnode, persistence, SMGR_AO); + srel = RelationCreateStorage(*newrnode, persistence, SMGR_MD); /* * If required, set up an init fork for an unlogged table so that it can @@ -1082,7 +1082,7 @@ appendonly_relation_set_new_filenode(Relation rel, rel->rd_rel->relkind == RELKIND_MATVIEW || rel->rd_rel->relkind == RELKIND_TOASTVALUE); smgrcreate(srel, INIT_FORKNUM, false); - log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_AO); + log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_MD); smgrimmedsync(srel, INIT_FORKNUM); } @@ -1124,7 +1124,7 @@ appendonly_relation_copy_data(Relation rel, const RelFileNode *newrnode) * Use the "AO-specific" (non-shared buffers backed storage) SMGR * implementation */ - dstrel = smgropen(*newrnode, rel->rd_backend, SMGR_AO); + dstrel = smgropen(*newrnode, rel->rd_backend, SMGR_MD); RelationOpenSmgr(rel); /* @@ -1134,7 +1134,7 @@ appendonly_relation_copy_data(Relation rel, const RelFileNode *newrnode) * NOTE: any conflict in relfilenode value will be caught in * RelationCreateStorage(). */ - RelationCreateStorage(*newrnode, rel->rd_rel->relpersistence, SMGR_AO); + RelationCreateStorage(*newrnode, rel->rd_rel->relpersistence, SMGR_MD); copy_append_only_data(rel->rd_node, *newrnode, rel->rd_backend, rel->rd_rel->relpersistence); @@ -1153,7 +1153,7 @@ appendonly_relation_copy_data(Relation rel, const RelFileNode *newrnode) */ smgrcreate(dstrel, INIT_FORKNUM, false); - log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_AO); + log_smgrcreate(newrnode, INIT_FORKNUM, SMGR_MD); } /* drop old relation, and close new one */ diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c index e2965408723d..115e25fd1b48 100644 --- a/src/backend/catalog/storage.c +++ b/src/backend/catalog/storage.c @@ -160,8 +160,7 @@ RelationDropStorage(Relation rel) pending->relnode.isTempRelation = rel->rd_backend == TempRelBackendId; pending->atCommit = true; /* delete if commit */ pending->nestLevel = GetCurrentTransactionNestLevel(); - pending->relnode.smgr_which = - RelationIsAppendOptimized(rel) ? SMGR_AO : SMGR_MD; + pending->relnode.smgr_which = SMGR_MD; pending->next = pendingDeletes; pendingDeletes = pending; diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 2c9a9bd71c18..8128085b4144 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -15834,7 +15834,7 @@ index_copy_data(Relation rel, RelFileNode newrnode) { SMgrRelation dstrel; - SMgrImpl smgr_which = RelationIsAppendOptimized(rel) ? SMGR_AO : SMGR_MD; + SMgrImpl smgr_which = SMGR_MD; dstrel = smgropen(newrnode, rel->rd_backend, smgr_which); diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index 319b922483d2..14daee609cb9 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -62,29 +62,6 @@ static const f_smgr smgrsw[] = { .smgr_nblocks = mdnblocks, .smgr_truncate = mdtruncate, .smgr_immedsync = mdimmedsync, - }, - /* - * Relation files that are different from heap, characterised by: - * 1. variable blocksize - * 2. block numbers are not consecutive - * 3. shared buffers are not used - * Append-optimized relation files currently fall in this category. - */ - { - .smgr_init = NULL, - .smgr_shutdown = NULL, - .smgr_close = mdclose, - .smgr_create = mdcreate, - .smgr_exists = mdexists, - .smgr_unlink = mdunlink_ao, - .smgr_extend = mdextend, - .smgr_prefetch = mdprefetch, - .smgr_read = mdread, - .smgr_write = mdwrite, - .smgr_writeback = mdwriteback, - .smgr_nblocks = mdnblocks, - .smgr_truncate = mdtruncate, - .smgr_immedsync = mdimmedsync, } }; @@ -167,7 +144,7 @@ const f_smgr * smgr_standard(BackendId backend, RelFileNode rnode, SMgrImpl which) { // for md.c - return &smgrsw[which]; + return &smgrsw[0]; } const f_smgr * diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index 4f49c06f03ba..5ed4eed5c972 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -23,8 +23,7 @@ typedef enum SMgrImplementation { - SMGR_MD = 0, - SMGR_AO = 1 + SMGR_MD = 0 } SMgrImpl; diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 6e12e6382b1e..c7b3d3a35984 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -571,7 +571,7 @@ typedef struct ViewOptions smgrsetowner(&((relation)->rd_smgr), \ smgropen((relation)->rd_node, \ (relation)->rd_backend, \ - RelationStorageIsAO(relation)?SMGR_AO:SMGR_MD)); \ + SMGR_MD)); \ } while (0) /*