Skip to content

Commit c2dcf70

Browse files
tristan957Commitfest Bot
authored and
Commitfest Bot
committed
Allow extensions to override the global storage manager
1 parent f67cb13 commit c2dcf70

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/backend/storage/smgr/smgr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ static int NSmgr = 0;
6969

7070
static Size LargestSMgrRelationSize = 0;
7171

72+
SMgrId storage_manager_id;
73+
7274
/*
7375
* Each backend has a hashtable that stores all extant SMgrRelation objects.
7476
* In addition, "unpinned" SMgrRelation objects are chained together in a list.
@@ -227,7 +229,7 @@ smgropen(RelFileLocator rlocator, ProcNumber backend)
227229
for (int i = 0; i <= MAX_FORKNUM; ++i)
228230
reln->smgr_cached_nblocks[i] = InvalidBlockNumber;
229231

230-
reln->smgr_which = MdSMgrId; /* we only have md.c at present */
232+
reln->smgr_which = storage_manager_id;
231233

232234
/* implementation-specific initialization */
233235
smgrsw[reln->smgr_which].smgr_open(reln);

src/backend/utils/init/miscinit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,8 @@ void
19311931
register_builtin_dynamic_managers(void)
19321932
{
19331933
mdsmgr_register();
1934+
1935+
storage_manager_id = MdSMgrId;
19341936
}
19351937

19361938
/*

src/include/storage/smgr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
typedef uint8 SMgrId;
2222

23+
extern PGDLLIMPORT SMgrId storage_manager_id;
24+
2325
/*
2426
* smgr.c maintains a table of SMgrRelation objects, which are essentially
2527
* cached file handles. An SMgrRelation is created (if not already present)

0 commit comments

Comments
 (0)