!1727 支持dolphin插件自动安装加载和升级

Merge pull request !1727 from 仲夏十三/dolphin
This commit is contained in:
opengauss-bot
2022-05-30 08:44:02 +00:00
committed by Gitee
6 changed files with 52 additions and 14 deletions

View File

@ -93,6 +93,7 @@ install:
$(MAKE) install_pldebugger
$(MAKE) -C contrib/postgres_fdw $@
$(MAKE) -C contrib/hstore $@
@if test -d contrib/dolphin; then $(MAKE) -C contrib/dolphin $@; fi
+@echo "openGauss installation complete."
endif
endif

View File

@ -60,6 +60,8 @@
./share/postgresql/extension/hstore.control
./share/postgresql/extension/security_plugin.control
./share/postgresql/extension/security_plugin--1.0.sql
./share/postgresql/extension/dolphin.control
./share/postgresql/extension/dolphin--1.0.sql
./share/postgresql/extension/file_fdw--1.0.sql
./share/postgresql/extension/plpgsql.control
./share/postgresql/extension/dist_fdw.control
@ -748,6 +750,7 @@
./lib/postgresql/pg_plugin
./lib/postgresql/proc_srclib
./lib/postgresql/security_plugin.so
./lib/postgresql/dolphin.so
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so

View File

@ -60,6 +60,8 @@
./share/postgresql/extension/hstore.control
./share/postgresql/extension/security_plugin.control
./share/postgresql/extension/security_plugin--1.0.sql
./share/postgresql/extension/dolphin.control
./share/postgresql/extension/dolphin--1.0.sql
./share/postgresql/extension/file_fdw--1.0.sql
./share/postgresql/extension/plpgsql.control
./share/postgresql/extension/dist_fdw.control
@ -749,6 +751,7 @@
./lib/postgresql/pg_plugin
./lib/postgresql/proc_srclib
./lib/postgresql/security_plugin.so
./lib/postgresql/dolphin.so
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so

View File

@ -60,6 +60,8 @@
./share/postgresql/extension/hstore.control
./share/postgresql/extension/security_plugin.control
./share/postgresql/extension/security_plugin--1.0.sql
./share/postgresql/extension/dolphin.control
./share/postgresql/extension/dolphin--1.0.sql
./share/postgresql/extension/file_fdw--1.0.sql
./share/postgresql/extension/plpgsql.control
./share/postgresql/extension/dist_fdw.control
@ -748,6 +750,7 @@
./lib/postgresql/pg_plugin
./lib/postgresql/proc_srclib
./lib/postgresql/security_plugin.so
./lib/postgresql/dolphin.so
./lib/postgresql/pg_upgrade_support.so
./lib/postgresql/java/pljava.jar
./lib/postgresql/postgres_fdw.so

View File

@ -822,17 +822,36 @@ void client_read_ended(void)
}
#ifndef ENABLE_MULTIPLE_NODES
#define INIT_PLUGIN_OBJECT "init_plugin_object"
void InitBSqlPluginHookIfNeeded()
{
const char* dolphin = "dolphin";
CFunInfo tmpCF;
tmpCF = load_external_function(dolphin, INIT_PLUGIN_OBJECT, false, false);
void ExecuteFunctionIfExisted(const char *filename, char *funcname)
{
CFunInfo tmpCF;
tmpCF = load_external_function(filename, funcname, false, false);
if (tmpCF.user_fn != NULL) {
((void* (*)(void))(tmpCF.user_fn))();
}
}
bool IsFileExisted(const char *filename)
{
char* fullname = expand_dynamic_library_name(filename);
return file_exists(fullname);
}
#define INIT_PLUGIN_OBJECT "init_plugin_object"
#define DOLPHIN "dolphin"
void InitBSqlPluginHookIfNeeded()
{
ExecuteFunctionIfExisted(DOLPHIN, INIT_PLUGIN_OBJECT);
}
#define LOAD_DOLPHIN "create_dolphin_extension"
void LoadDolphinIfNeeded()
{
if (IsFileExisted(DOLPHIN)) {
ExecuteFunctionIfExisted(DOLPHIN, LOAD_DOLPHIN);
}
}
#endif
/*
@ -7574,8 +7593,12 @@ int PostgresMain(int argc, char* argv[], const char* dbname, const char* usernam
init_set_params_htab();
#ifndef ENABLE_MULTIPLE_NODES
if (u_sess->proc_cxt.MyDatabaseId != InvalidOid && DB_IS_CMPT(B_FORMAT) && u_sess->attr.attr_sql.dolphin) {
InitBSqlPluginHookIfNeeded();
if (u_sess->proc_cxt.MyDatabaseId != InvalidOid && DB_IS_CMPT(B_FORMAT)) {
if (!u_sess->attr.attr_sql.dolphin) {
LoadDolphinIfNeeded();
} else {
InitBSqlPluginHookIfNeeded();
}
}
#endif

View File

@ -771,6 +771,7 @@ static void init_session_share_memory()
#ifndef ENABLE_MULTIPLE_NODES
extern void InitBSqlPluginHookIfNeeded();
extern void LoadDolphinIfNeeded();
#endif
static bool InitSession(knl_session_context* session)
@ -847,16 +848,20 @@ static bool InitSession(knl_session_context* session)
t_thrd.proc_cxt.PostInit->SetDatabaseAndUser(dbname, InvalidOid, username);
t_thrd.proc_cxt.PostInit->InitSession();
#ifndef ENABLE_MULTIPLE_NODES
if (u_sess->proc_cxt.MyDatabaseId != InvalidOid && DB_IS_CMPT(B_FORMAT) && u_sess->attr.attr_sql.dolphin) {
InitBSqlPluginHookIfNeeded();
}
#endif
Assert(CheckMyDatabaseMatch());
SetProcessingMode(NormalProcessing);
#ifndef ENABLE_MULTIPLE_NODES
if (u_sess->proc_cxt.MyDatabaseId != InvalidOid && DB_IS_CMPT(B_FORMAT)) {
if (!u_sess->attr.attr_sql.dolphin) {
LoadDolphinIfNeeded();
} else {
InitBSqlPluginHookIfNeeded();
}
}
#endif
init_session_share_memory();
BeginReportingGUCOptions();