jiaqizho commented on code in PR #763:
URL: https://github.com/apache/cloudberry/pull/763#discussion_r1881297824
##########
src/backend/storage/smgr/smgr.c:
##########
@@ -128,6 +128,74 @@ static dlist_head unowned_relns;
/* local function prototypes */
static void smgrshutdown(int code, Datum arg);
+SMgrImpl smgr_register(const f_smgr *smgr, SMgrImpl smgr_impl)
+{
+ if (!process_shared_preload_libraries_in_progress)
+ {
+ ereport(ERROR, (errmsg("smgr_register not in
shared_preload_libraries")));
+ }
+
+ if (smgr_impl > SMGR_MAX_ID)
+ {
+ elog(ERROR, "smgr_impl is out of range");
+ }
+
+ if (smgr->smgr_name == NULL)
+ {
+ elog(ERROR, "smgr_name is not set");
+ }
+
+ // check if the smgr_impl is already registered, avoid conflict with
existing smgr_impl
+ if (smgrsw[smgr_impl].smgr_name != NULL)
+ {
+ elog(ERROR, "smgr_impl is already registered");
+ }
+
+ smgrsw[smgr_impl] = *smgr;
+ return smgr_impl;
+}
+
+const f_smgr *smgr_get(SMgrImpl smgr_impl)
+{
+ if (smgr_impl > SMGR_MAX_ID)
+ {
+ elog(ERROR, "smgr_impl is out of range");
+ }
+
+ if (smgrsw[smgr_impl].smgr_name == NULL)
+ {
+ elog(ERROR, "smgr_impl is not registered");
+ }
+
+ return &smgrsw[smgr_impl];
+}
+
+/*
+ * smgr_get_impl() is used to get the smgr id of the relation.
+ *
+ * FIXME: For PAX_AM_OID, Cloudberrydb reserves this value for ORCA, a
+ * predefined value is used here to reserve the smgr id for PAX_AM_OID.
+ * should we add a hook to get the smgr id of the relation?
+ */
+SMgrImpl smgr_get_impl(const Relation rel)
+{
+ SMgrImpl smgr_impl = SMGR_INVALID;
+
+ if (RelationIsAppendOptimized(rel))
+ {
+ smgr_impl = SMGR_AO;
+ }
+ else if (rel->rd_rel->relam == PAX_AM_OID)
+ {
+ smgr_impl = SMGR_PAX;
+ }
+ else
Review Comment:
```
else {
hook() -> impl ?
else {
smgr_impl = SMGR_MD;
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]