diff --git a/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp b/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp index 1e95e8d45d..0f9e57785e 100644 --- a/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp +++ b/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp @@ -710,7 +710,7 @@ int ObInnerTableSchema::routines_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__(select CAST(mp.specific_name AS CHAR(64)) AS SPECIFIC_NAME, CAST('def' AS CHAR(512)) as ROUTINE_CATALOG, CAST(mp.db AS CHAR(64)) collate utf8mb4_name_case as ROUTINE_SCHEMA, CAST(mp.name AS CHAR(64)) as ROUTINE_NAME, CAST(mp.type AS CHAR(9)) as ROUTINE_TYPE, CAST(lower(v.data_type_str) AS CHAR(64)) AS DATA_TYPE, CAST( CASE WHEN mp.type = 'FUNCTION' THEN CASE WHEN rp.param_type IN (22, 23, 27, 28, 29, 30) THEN rp.param_length ELSE NULL END ELSE NULL END AS SIGNED ) as CHARACTER_MAXIMUM_LENGTH, CASE WHEN rp.param_type IN (22, 23, 27, 28, 29, 30, 43, 44, 46) THEN CAST( rp.param_length * CASE rp.param_coll_type WHEN 63 THEN 1 WHEN 249 THEN 4 WHEN 248 THEN 4 WHEN 87 THEN 2 WHEN 28 THEN 2 WHEN 55 THEN 4 WHEN 54 THEN 4 WHEN 101 THEN 2 WHEN 46 THEN 4 WHEN 45 THEN 4 WHEN 224 THEN 4 ELSE 1 END AS SIGNED ) ELSE CAST(NULL AS SIGNED) END AS CHARACTER_OCTET_LENGTH, CASE WHEN rp.param_type IN (1, 2, 3, 4, 5, 15, 16, 50) THEN CAST(rp.param_precision AS UNSIGNED) ELSE CAST(NULL AS UNSIGNED) END AS NUMERIC_PRECISION, CASE WHEN rp.param_type IN (15, 16, 50) THEN CAST(rp.param_scale AS SIGNED) WHEN rp.param_type IN (1, 2, 3, 4, 5, 11, 12, 13, 14) THEN CAST(0 AS SIGNED) ELSE CAST(NULL AS SIGNED) END AS NUMERIC_SCALE, CASE WHEN rp.param_type IN (17, 18, 20) THEN CAST(rp.param_scale AS UNSIGNED) ELSE CAST(NULL AS UNSIGNED) END AS DATETIME_PRECISION, CAST( CASE rp.param_charset WHEN 1 THEN 'binary' WHEN 2 THEN 'utf8mb4' WHEN 3 THEN 'gbk' WHEN 4 THEN 'utf16' WHEN 5 THEN 'gb18030' WHEN 6 THEN 'latin1' WHEN 7 THEN 'gb18030_2022' ELSE NULL END AS CHAR(64) ) AS CHARACTER_SET_NAME, CAST( CASE rp.param_coll_type WHEN 45 THEN 'utf8mb4_general_ci' WHEN 46 THEN 'utf8mb4_bin' WHEN 63 THEN 'binary' ELSE NULL END AS CHAR(64) ) AS COLLATION_NAME, CAST( CASE WHEN rp.param_type IN (1, 2, 3, 4, 5) THEN CONCAT( lower(v.data_type_str), '(', rp.param_precision, ')' ) WHEN rp.param_type IN (15, 16, 50) THEN CONCAT( lower(v.data_type_str), '(', rp.param_precision, ',', rp.param_scale, ')' ) WHEN rp.param_type IN (18, 20) THEN CONCAT(lower(v.data_type_str), '(', rp.param_scale, ')') WHEN rp.param_type IN (22, 23) and rp.param_length > 0 THEN CONCAT(lower(v.data_type_str), '(', rp.param_length, ')') ELSE lower(v.data_type_str) END AS CHAR(4194304) ) AS DTD_IDENTIFIER, CAST('SQL' AS CHAR(8)) as ROUTINE_BODY, CAST(mp.body AS CHAR(4194304)) as ROUTINE_DEFINITION, CAST(NULL AS CHAR(64)) as EXTERNAL_NAME, CAST(NULL AS CHAR(64)) as EXTERNAL_LANGUAGE, CAST('SQL' AS CHAR(8)) as PARAMETER_STYLE, CAST(mp.IS_DETERMINISTIC AS CHAR(3)) AS IS_DETERMINISTIC, CAST(mp.SQL_DATA_ACCESS AS CHAR(64)) AS SQL_DATA_ACCESS, CAST(NULL AS CHAR(64)) as SQL_PATH, CAST(mp.SECURITY_TYPE AS CHAR(7)) as SECURITY_TYPE, CAST(r.gmt_create AS datetime) as CREATED, CAST(r.gmt_modified AS datetime) as LAST_ALTERED, CAST(mp.SQL_MODE AS CHAR(8192)) as SQL_MODE, CAST(mp.comment AS CHAR(4194304)) as ROUTINE_COMMENT, CAST(mp.DEFINER AS CHAR(93)) as DEFINER, CAST(mp.CHARACTER_SET_CLIENT AS CHAR(32)) as CHARACTER_SET_CLIENT, CAST(mp.COLLATION_CONNECTION AS CHAR(32)) as COLLATION_CONNECTION, CAST(mp.db_collation AS CHAR(32)) as DATABASE_COLLATION from mysql.proc as mp join oceanbase.__all_database a on mp.DB = a.DATABASE_NAME join oceanbase.__all_routine as r on mp.specific_name = r.routine_name and r.DATABASE_ID = a.DATABASE_ID left join oceanbase.__all_routine_param as rp on rp.subprogram_id = r.subprogram_id and rp.tenant_id = r.tenant_id and rp.routine_id = r.routine_id and rp.param_position = 0 left join oceanbase.__all_virtual_data_type v on rp.param_type = v.data_type )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__(select CAST(mp.specific_name AS CHAR(64)) AS SPECIFIC_NAME, CAST('def' AS CHAR(512)) as ROUTINE_CATALOG, CAST(mp.db AS CHAR(64)) collate utf8mb4_name_case as ROUTINE_SCHEMA, CAST(mp.name AS CHAR(64)) as ROUTINE_NAME, CAST(mp.type AS CHAR(9)) as ROUTINE_TYPE, CAST(lower(v.data_type_str) AS CHAR(64)) AS DATA_TYPE, CAST( CASE WHEN mp.type = 'FUNCTION' THEN CASE WHEN rp.param_type IN (22, 23, 27, 28, 29, 30) THEN rp.param_length ELSE NULL END ELSE NULL END AS SIGNED ) as CHARACTER_MAXIMUM_LENGTH, CASE WHEN rp.param_type IN (22, 23, 27, 28, 29, 30, 43, 44, 46) THEN CAST( rp.param_length * CASE rp.param_coll_type WHEN 63 THEN 1 WHEN 249 THEN 4 WHEN 248 THEN 4 WHEN 87 THEN 2 WHEN 28 THEN 2 WHEN 55 THEN 4 WHEN 54 THEN 4 WHEN 101 THEN 2 WHEN 46 THEN 4 WHEN 45 THEN 4 WHEN 224 THEN 4 ELSE 1 END AS SIGNED ) ELSE CAST(NULL AS SIGNED) END AS CHARACTER_OCTET_LENGTH, CASE WHEN rp.param_type IN (1, 2, 3, 4, 5, 15, 16, 50) THEN CAST(rp.param_precision AS UNSIGNED) ELSE CAST(NULL AS UNSIGNED) END AS NUMERIC_PRECISION, CASE WHEN rp.param_type IN (15, 16, 50) THEN CAST(rp.param_scale AS SIGNED) WHEN rp.param_type IN (1, 2, 3, 4, 5, 11, 12, 13, 14) THEN CAST(0 AS SIGNED) ELSE CAST(NULL AS SIGNED) END AS NUMERIC_SCALE, CASE WHEN rp.param_type IN (17, 18, 20) THEN CAST(rp.param_scale AS UNSIGNED) ELSE CAST(NULL AS UNSIGNED) END AS DATETIME_PRECISION, CAST( CASE rp.param_charset WHEN 1 THEN 'binary' WHEN 2 THEN 'utf8mb4' WHEN 3 THEN 'gbk' WHEN 4 THEN 'utf16' WHEN 5 THEN 'gb18030' WHEN 6 THEN 'latin1' WHEN 7 THEN 'gb18030_2022' ELSE NULL END AS CHAR(64) ) AS CHARACTER_SET_NAME, CAST( CASE rp.param_coll_type WHEN 45 THEN 'utf8mb4_general_ci' WHEN 46 THEN 'utf8mb4_bin' WHEN 63 THEN 'binary' ELSE NULL END AS CHAR(64) ) AS COLLATION_NAME, CAST( CASE WHEN rp.param_type IN (1, 2, 3, 4, 5) THEN CONCAT( lower(v.data_type_str), '(', rp.param_precision, ')' ) WHEN rp.param_type IN (15, 16, 50) THEN CONCAT( lower(v.data_type_str), '(', rp.param_precision, ',', rp.param_scale, ')' ) WHEN rp.param_type IN (18, 20) THEN CONCAT(lower(v.data_type_str), '(', rp.param_scale, ')') WHEN rp.param_type IN (22, 23) and rp.param_length > 0 THEN CONCAT(lower(v.data_type_str), '(', rp.param_length, ')') ELSE lower(v.data_type_str) END AS CHAR(4194304) ) AS DTD_IDENTIFIER, CAST('SQL' AS CHAR(8)) as ROUTINE_BODY, CAST(mp.body AS CHAR(4194304)) as ROUTINE_DEFINITION, CAST(NULL AS CHAR(64)) as EXTERNAL_NAME, CAST(NULL AS CHAR(64)) as EXTERNAL_LANGUAGE, CAST('SQL' AS CHAR(8)) as PARAMETER_STYLE, CAST(mp.IS_DETERMINISTIC AS CHAR(3)) AS IS_DETERMINISTIC, CAST(mp.SQL_DATA_ACCESS AS CHAR(64)) AS SQL_DATA_ACCESS, CAST(NULL AS CHAR(64)) as SQL_PATH, CAST(mp.SECURITY_TYPE AS CHAR(7)) as SECURITY_TYPE, CAST(r.gmt_create AS datetime) as CREATED, CAST(r.gmt_modified AS datetime) as LAST_ALTERED, CAST(mp.SQL_MODE AS CHAR(8192)) as SQL_MODE, CAST(mp.comment AS CHAR(4194304)) as ROUTINE_COMMENT, CAST(mp.DEFINER AS CHAR(93)) as DEFINER, CAST(mp.CHARACTER_SET_CLIENT AS CHAR(32)) as CHARACTER_SET_CLIENT, CAST(mp.COLLATION_CONNECTION AS CHAR(32)) as COLLATION_CONNECTION, CAST(mp.db_collation AS CHAR(32)) as DATABASE_COLLATION from mysql.proc as mp join oceanbase.__all_database a on mp.DB = a.DATABASE_NAME and a.in_recyclebin = 0 join oceanbase.__all_routine as r on mp.specific_name = r.routine_name and r.DATABASE_ID = a.DATABASE_ID and CAST( CASE r.routine_type WHEN 1 THEN 'PROCEDURE' WHEN 2 THEN 'FUNCTION' ELSE NULL END AS CHAR(9) ) = mp.type left join oceanbase.__all_routine_param as rp on rp.subprogram_id = r.subprogram_id and rp.tenant_id = r.tenant_id and rp.routine_id = r.routine_id and rp.param_position = 0 left join oceanbase.__all_virtual_data_type v on rp.param_type = v.data_type )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema_def.py b/src/share/inner_table/ob_inner_table_schema_def.py index 1742949cb8..df16dd960f 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -15776,8 +15776,18 @@ def_table_schema( mysql.proc as mp join oceanbase.__all_database a on mp.DB = a.DATABASE_NAME + and a.in_recyclebin = 0 join oceanbase.__all_routine as r on mp.specific_name = r.routine_name and r.DATABASE_ID = a.DATABASE_ID + and + CAST( + CASE r.routine_type + WHEN 1 THEN 'PROCEDURE' + WHEN 2 THEN 'FUNCTION' + ELSE NULL + END + AS CHAR(9) + ) = mp.type left join oceanbase.__all_routine_param as rp on rp.subprogram_id = r.subprogram_id and rp.tenant_id = r.tenant_id and rp.routine_id = r.routine_id