diff --git a/src/gausskernel/optimizer/commands/dropcmds.cpp b/src/gausskernel/optimizer/commands/dropcmds.cpp index d407ff061..1b819b9b5 100644 --- a/src/gausskernel/optimizer/commands/dropcmds.cpp +++ b/src/gausskernel/optimizer/commands/dropcmds.cpp @@ -55,6 +55,35 @@ static bool CheckObjectDropPrivilege(ObjectType removeType, Oid objectId) } return (aclresult == ACLCHECK_OK) ? true : false; } + +static void DropExtensionIsSupported(List* objname) +{ + static const char *supportList[] = { + "postgis", + "packages", +#ifndef ENABLE_MULTIPLE_NODES + "mysql_fdw", + "oracle_fdw", + "postgres_fdw", + "dblink", + "db_a_parser", + "db_b_parser", + "db_c_parser", + "db_pg_parser", +#endif + }; + int len = lengthof(supportList); + const char* name = strVal(linitial(objname)); + + for (int i = 0; i < len; i++) { + if (pg_strcasecmp(name, supportList[i]) == 0) { + return; + } + } + + ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("EXTENSION is not yet supported."))); +} + /* * @Description: drop one or more objects. * We don't currently handle all object types here. Relations, for example, @@ -97,6 +126,8 @@ void RemoveObjects(DropStmt* stmt, bool missing_ok, bool is_securityadmin) missing_ok = stmt->missing_ok; does_not_exist_skipping(stmt->removeType, objname, objargs, missing_ok); continue; + } else if (stmt->removeType == OBJECT_EXTENSION) { + DropExtensionIsSupported(objname); } /* diff --git a/src/gausskernel/process/tcop/utility.cpp b/src/gausskernel/process/tcop/utility.cpp index 878a6a983..b5bcd098d 100644 --- a/src/gausskernel/process/tcop/utility.cpp +++ b/src/gausskernel/process/tcop/utility.cpp @@ -9445,30 +9445,6 @@ bool IsVariableinBlackList(const char* name) return isInBlackList; } -/* - * return true if the extension can be uninstall - */ -bool DropExtensionIsSupported(const char* query_string) -{ - char* lower_string = lowerstr(query_string); - -#ifndef ENABLE_MULTIPLE_NODES - if (strstr(lower_string, "drop") && (strstr(lower_string, "postgis") || strstr(lower_string, "packages") || - strstr(lower_string, "mysql_fdw") || strstr(lower_string, "oracle_fdw") || - strstr(lower_string, "postgres_fdw") || strstr(lower_string, "dblink") || - strstr(lower_string, "db_b_parser") || strstr(lower_string, "db_a_parser") || - strstr(lower_string, "db_c_parser") || strstr(lower_string, "db_pg_parser"))) { -#else - if (strstr(lower_string, "drop") && (strstr(lower_string, "postgis") || strstr(lower_string, "packages"))) { -#endif - pfree_ext(lower_string); - return true; - } else { - pfree_ext(lower_string); - return false; - } -} - /* * Check if the object is in blacklist, if true, ALTER/DROP operation of the object is disabled. * Note that only prescribed extensions are able droppable. @@ -9480,12 +9456,8 @@ void CheckObjectInBlackList(ObjectType obj_type, const char* query_string) switch (obj_type) { case OBJECT_EXTENSION: - tag = "EXTENSION"; - /* Check if the extension is provided officially */ - if (DropExtensionIsSupported(query_string)) - return; - else - break; + /* Check black list in RemoveObjects */ + return; #ifdef ENABLE_MULTIPLE_NODES case OBJECT_AGGREGATE: tag = "AGGREGATE"; diff --git a/src/gausskernel/process/threadpool/threadpool_controler.cpp b/src/gausskernel/process/threadpool/threadpool_controler.cpp index 1ba912988..2195b0878 100644 --- a/src/gausskernel/process/threadpool/threadpool_controler.cpp +++ b/src/gausskernel/process/threadpool/threadpool_controler.cpp @@ -262,7 +262,7 @@ void ThreadPoolControler::ParseBindCpu() bindNum = ParseRangeStr(psave, m_cpuInfo.isBindCpuArr, m_cpuInfo.totalCpuNum, "cpubind"); } else if (strncmp("nodebind", ptoken, strlen("nodebind")) == 0) { m_cpuInfo.bindType = NODE_BIND; - m_cpuInfo.isBindNumaArr = (bool*)palloc0(sizeof(bool) * m_cpuInfo.totalCpuNum); + m_cpuInfo.isBindNumaArr = (bool*)palloc0(sizeof(bool) * m_cpuInfo.totalNumaNum); bindNum = ParseRangeStr(psave, m_cpuInfo.isBindNumaArr, m_cpuInfo.totalNumaNum, "nodebind"); } else { INVALID_ATTR_ERROR(errdetail("Only 'nobind', 'allbind', 'cpubind', and 'nodebind' are valid attribute.")); diff --git a/src/test/regress/expected/drop_if_exists.out b/src/test/regress/expected/drop_if_exists.out index 7091bfc49..6b3fe60f9 100644 --- a/src/test/regress/expected/drop_if_exists.out +++ b/src/test/regress/expected/drop_if_exists.out @@ -127,10 +127,16 @@ NOTICE: text search configuration "test_tsconfig_exists" does not exist, skippi CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (COPY=english); DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists; -- extension +-- doesn't exists DROP EXTENSION test_extension_exists; ERROR: extension "test_extension_exists" does not exist DROP EXTENSION IF EXISTS test_extension_exists; NOTICE: extension "test_extension_exists" does not exist, skipping +-- exists but doesn't support drop +DROP EXTENSION plpgsql; +ERROR: EXTENSION is not yet supported. +DROP EXTENSION IF EXISTS plpgsql; +ERROR: EXTENSION is not yet supported. -- functions DROP FUNCTION test_function_exists(); ERROR: function test_function_exists does not exist diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index 73410be62..049608d1f 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -483,7 +483,8 @@ test: copyselect copy_error_log # Another group of parallel tests # ---------- test: create_function_3 vacuum -#test: constraints drop_if_exists +test: drop_if_exists +#test: constraints #test: errors subplan_base test: subplan_new diff --git a/src/test/regress/sql/drop_if_exists.sql b/src/test/regress/sql/drop_if_exists.sql index 87d9984ae..7fee2a4b3 100644 --- a/src/test/regress/sql/drop_if_exists.sql +++ b/src/test/regress/sql/drop_if_exists.sql @@ -142,8 +142,12 @@ CREATE TEXT SEARCH CONFIGURATION test_tsconfig_exists (COPY=english); DROP TEXT SEARCH CONFIGURATION test_tsconfig_exists; -- extension +-- doesn't exists DROP EXTENSION test_extension_exists; DROP EXTENSION IF EXISTS test_extension_exists; +-- exists but doesn't support drop +DROP EXTENSION plpgsql; +DROP EXTENSION IF EXISTS plpgsql; -- functions DROP FUNCTION test_function_exists();