Prepare to support multiple SMGR implementations.
authorThomas Munro <thomas.munro@gmail.com>
Wed, 17 Jul 2019 02:15:27 +0000 (14:15 +1200)
committerThomas Munro <thomas.munro@gmail.com>
Wed, 17 Jul 2019 03:28:27 +0000 (15:28 +1200)
Move the "which" decision into a function that later patches can add
to.

Author: Thomas Munro

src/backend/storage/smgr/smgr.c

index b0d9f21e6880e69ad9eac2baebb30c77a5654c8c..d00b275e468a6d91a5ec98d2d97ea3307e1d3f17 100644 (file)
@@ -97,6 +97,18 @@ static dlist_head unowned_relns;
 /* local function prototypes */
 static void smgrshutdown(int code, Datum arg);
 
+/*
+ * Which implementation should handle a given RelFileNode?
+ */
+static int
+smgrwhich(RelFileNode rnode)
+{
+       switch (rnode.dbNode)
+       {
+               default:
+                       return 0;                       /* md.c */
+       }
+}
 
 /*
  *     smgrinit(), smgrshutdown() -- Initialize or shut down storage
@@ -176,7 +188,7 @@ smgropen(RelFileNode rnode, BackendId backend)
                reln->smgr_targblock = InvalidBlockNumber;
                reln->smgr_fsm_nblocks = InvalidBlockNumber;
                reln->smgr_vm_nblocks = InvalidBlockNumber;
-               reln->smgr_which = 0;   /* we only have md.c at present */
+               reln->smgr_which = smgrwhich(rnode);
 
                /* implementation-specific initialization */
                smgrsw[reln->smgr_which].smgr_open(reln);