diff --git a/GNUmakefile.in b/GNUmakefile.in index 8bc0009bd..4051e3c23 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -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 diff --git a/build/script/aarch64_opengauss_list b/build/script/aarch64_opengauss_list index 89af4cb2f..67c2c55a1 100644 --- a/build/script/aarch64_opengauss_list +++ b/build/script/aarch64_opengauss_list @@ -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 diff --git a/build/script/opengauss_release_list_ubuntu_single b/build/script/opengauss_release_list_ubuntu_single index 52ba5da88..03f628843 100644 --- a/build/script/opengauss_release_list_ubuntu_single +++ b/build/script/opengauss_release_list_ubuntu_single @@ -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 diff --git a/build/script/x86_64_opengauss_list b/build/script/x86_64_opengauss_list index 4632f2342..d2c3c7fbc 100644 --- a/build/script/x86_64_opengauss_list +++ b/build/script/x86_64_opengauss_list @@ -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 diff --git a/src/gausskernel/process/tcop/postgres.cpp b/src/gausskernel/process/tcop/postgres.cpp index 04ac21d15..c9e777ce4 100755 --- a/src/gausskernel/process/tcop/postgres.cpp +++ b/src/gausskernel/process/tcop/postgres.cpp @@ -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 diff --git a/src/gausskernel/process/threadpool/threadpool_worker.cpp b/src/gausskernel/process/threadpool/threadpool_worker.cpp index ac92f6a8c..4f2dbd483 100644 --- a/src/gausskernel/process/threadpool/threadpool_worker.cpp +++ b/src/gausskernel/process/threadpool/threadpool_worker.cpp @@ -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();