!2503 单机下禁止创建language java function

Merge pull request !2503 from pengjiong/fix_case
This commit is contained in:
opengauss-bot
2022-11-30 09:53:04 +00:00
committed by Gitee
3 changed files with 15 additions and 9 deletions

View File

@ -1093,25 +1093,28 @@ void CreateFunction(CreateFunctionStmt* stmt, const char* queryString, Oid pkg_o
u_sess->plsql_cxt.isCreateFunction = false;
}
#ifdef ENABLE_MULTIPLE_NODES
if (languageOid == JavalanguageId) {
#ifdef ENABLE_MULTIPLE_NODES
/*
* single node dose not support Java UDF or other fenced functions.
* check it here because users may not know the Java UDF is fenced by default,
* so it's better to report detailed error messages for different senarios.
*/
if (IS_SINGLE_NODE) {
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("JAVA UDF is not yet supported in current version.")));
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("JAVA UDF is not yet supported in current version.")));
}
/* only support fenced mode Java UDF */
if (!fenced) {
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Java UDF dose not support NOT FENCED functions.")));
ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("Java UDF dose not support NOT FENCED functions.")));
}
}
#else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("JAVA UDF is not yet supported in current version.")));
#endif
}
languageStruct = (Form_pg_language)GETSTRUCT(languageTuple);

View File

@ -15,8 +15,9 @@ CREATE FUNCTION java_getSystemProperty(VARCHAR)
RETURNS VARCHAR
AS 'java.lang.System.getProperty'
LANGUAGE java NOT FENCED;
ERROR: JAVA UDF is not yet supported in current version.
CREATE FUNCTION java_getSystemProperty(VARCHAR)
RETURNS VARCHAR
AS 'java.lang.System.getProperty'
LANGUAGE java FENCED;
ERROR: function "java_getsystemproperty" already exists with same argument types
ERROR: JAVA UDF is not yet supported in current version.

View File

@ -172,15 +172,17 @@ CREATE FUNCTION java_upperstring(VARCHAR)
RETURNS VARCHAR
AS 'Example.upperString'
LANGUAGE JAVA;
ERROR: JAVA UDF is not yet supported in current version.
set role p1 password 'udftest@123';
CREATE RESOURCE LABEL namecol ADD COLUMN(udftest.users.Name);
CREATE MASKING POLICY pol_name public.java_upperstring ON LABEL(namecol);
ERROR: failed to mask
DETAIL: wrong masking function
ERROR: Don't find function which can be used by masking
DETAIL: function should be created by poladmin or function is not found
drop RESOURCE LABEL namecol;
\c
--drop udf
drop FUNCTION java_upperstring;
ERROR: function java_upperstring does not exist
drop masking policy pol_creditcard;
drop masking policy pol_sal;
drop masking policy pol_phone;