Global Plsql Cache特性函数
- invalidate_plsql_object(),invalidate_plsql_object(schema, objname, objtype)
描述:失效Global Plsql Cache全局缓存中的对象,仅在enable_global_plsqlcache = on时可用。当前版本分布式不支持该函数使用。调用该函数的用户需要具有SYSADMIN权限。
参数:该函数为重载函数。当无入参时,将所有DATABASE内的所有全局缓存对象失效。
当指定schema、objname、objtype三个参数时可将当前DATABASE内的指定全局缓存对象失效。其中:schema为对象所属的schema名称;objname为对象名称;objtype为对象类型,对象为package类型时值为“package”,对象为函数或存储过程时值为“function”。
- gs_plsql_memory_object_detail(db_oid, obj_oid, obj_type)
描述:获取存储过程创建的package、function的主要有效内存占用情况。enable_global_plsqlcache = off时该函数显示当前session中的存储过程内存情况,跨session查询暂不支持。当前版本分布式不支持该函数使用。调用该函数的用户需要有SYSADMIN权限。
参数:该函数需传入db_oid、obj_oid、obj_type三个参数,如传入参数不匹配,返回空行。具体参数说明见表1。其中db_oid、obj_oid传入0为默认查找cache中所有package、function的有效内存使用情况。
返回值类型:Tuple
表1 gs_plsql_memory_object_detail参数说明 参数列表
类型
描述
取值范围
db_oid
uint32
查询数据库oid为db_oid内存储的存储过程的主要有效内存占用情况。0默认为当前缓存中全部数据库实例。
0 - 2^32-1。
obj_oid
uint32
查询object的oid。0默认为当前缓存中全部pkg与function。
0 - 2 ^32-1。
obj_type
text
查询object的类型,标识查询目标object为package或function。
all:默认全部查询。
pkg:查询满足条件的package有效内存占用。
func:查询满足条件的function有效内存占用。
func_in_pkg:查询满足条件的package中的function的有效内存占用。
gs_plsql_memory_object_detail函数显示数据库内满足查询条件的有效内存占用情况说明如表2所示。
表2 gs_plsql_memory_object_detail返回值 名称
类型
描述
object_oid
uint32
查询内存对象的oid。
context_name
text
内存对象名。
item
text
查询内存对象项目名。
searchpath
text
内存对象访问编译产物的Schema及其他环境变量。
guc
uint64
创建对象时的环境参数,即behavior_compat_flags的值。
file
text
内存对象创建所在文件。
line
uint32
内存对象创建所在文件行数。
size
uint32
内存对象大小。
db_oid
uint32
查询内存对象所在数据库oid。
- dump_plsql_compiled_object(object_id, object_type)
描述:打印存储过程的PACKAGE、FUNCTION编译产物信息。GUC参数enable_global_plsqlcache设置为off时,该函数只能查找当前session内的编译产物信息。暂不支持跨session、跨database查询。调用该函数需要有SYSADMIN权限。
参数:该函数需要传入object_oid和object_type两个参数,如果传入参数的数量或者类型不匹配,返回报错。具体参数说明如表3所示。
返回值类型:text
表3 dump_plsql_compiled_object参数说明 参数列表
类型
描述
取值范围
object_oid
uint32
查询object的oid。
0~2^32-1。
object_type
text
查询object的类型(不区分大小写)。
- "package":查询object类型为package。
- "function":查询object类型为function(查询效果与procedure等价)。
- "procedure":查询object类型为procedure(查询效果与function等价)。
示例:
-- 如下用例构造当GUC参数enable_global_plsqlcache设置为off时,创建存储过程,调用dump_plsql_compiled_object打印存储过程编译产物信息的情况。 gaussdb=# \x Expanded display is on. gaussdb=# CREATE OR REPLACE PROCEDURE test_proc(a out int, b out int) AS gaussdb$# BEGIN gaussdb$# a := 1; gaussdb$# b := 1; gaussdb$# END; gaussdb$# / CREATE PROCEDURE gaussdb=# SELECT test_proc(); -[ RECORD 1 ]---- test_proc | (1,1) gaussdb=# SELECT oid FROM pg_proc WHERE proname = 'test_proc'; -[ RECORD 1 ] oid | 16388 gaussdb=# SELECT * FROM dump_plsql_compiled_object(16388, 'function'); -[ RECORD 1 ]--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ dump_plsql_compiled_object | PL/pgSQL compiled function info: | fn_oid: 16388 | pkg_oid: 0 | namespace_oid: 2200 | fn_owner: 10 | fn_input_collation: 0 | fn_xmin: 195809 | fn_signature: test_proc() | fn_searchpath:{ 2200 , addCatalog: true, addTemp: true, addUser: false} | fn_rettype: 2249 | fn_rettyplen: 4294967295 | fn_rettypioparam: 0 | glc_func_life: 2 | fn_retbyval: false | fn_retistuple: true | fn_retset: false | fn_readonly: false | is_private: false | fn_is_trigger: false | pre_parse_trig: false | is_autonomous: false | is_inline_handler: false | is_plpgsql_func_with_outparam: false | need_skip_process_autonm_pkg: false | remembered_by_resowner: false | out_param_varno: 2 | found_varno: 3 | fn_nallargs: 2 | sql_cursor_found_varno: 4 | sql_notfound_varno: 5 | sql_isopen_varno: 6 | sql_rowcount_varno: 7 | sql_bulk_exceptions_varno: 0 | sqlcode_varno: 8 | sqlstate_varno: 9 | sqlerrm_varno: 10 | retvarno: 0 | guc_stat: 0 | ref_count: 0 | resolve_option: 0 | ndatums: 11 | datums:{ | type: GSPLSQL_DTYPE_VAR, dno: 0 ispkg: false refname: $1 isImplicit: false addNamespace: false pkg_oid: 0 varname: a isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: int4, typoid: 23, ttype: 0, typlen: 4, typrelid: 0, typioparam: 23, collation: 0, typinput_oid: 42, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 1 ispkg: false refname: $2 isImplicit: false addNamespace: false pkg_oid: 0 varname: b isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: int4, typoid: 23, ttype: 0, typlen: 4, typrelid: 0, typioparam: 23, collation: 0, typinput_oid: 42, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_ROW, dno: 2 ispkg: false refname: (null) isImplicit: true addNamespace: false pkg_oid: 0, varname: (null), | TupleDesc: tdTableAmType: 0, tdisredistable: false, attrs:{ 0: 23 1: 23 } | tdtypeid: 2249, tdtypmod: -1, tdhasoid: false, tdrefcount: -1, tdhasuids: false, | customErrorCode: 0, intoplaceholders: 0, recordVarTypOid: 0, hasExceptionInit: false, is_diff_pkg_cursor: false | default_val: nfields: 2, row fields:{ $1 = var 0 $2 = var 1 } | type: GSPLSQL_DTYPE_VAR, dno: 3 ispkg: false refname: found isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: bool, typoid: 16, ttype: 0, typlen: 1, typrelid: 0, typioparam: 16, collation: 0, typinput_oid: 1242, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 4 ispkg: false refname: __gsdb_sql_cursor_attri_found__ isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: bool, typoid: 16, ttype: 0, typlen: 1, typrelid: 0, typioparam: 16, collation: 0, typinput_oid: 1242, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 5 ispkg: false refname: __gsdb_sql_cursor_attri_notfound__ isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: bool, typoid: 16, ttype: 0, typlen: 1, typrelid: 0, typioparam: 16, collation: 0, typinput_oid: 1242, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 6 ispkg: false refname: __gsdb_sql_cursor_attri_isopen__ isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: bool, typoid: 16, ttype: 0, typlen: 1, typrelid: 0, typioparam: 16, collation: 0, typinput_oid: 1242, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 7 ispkg: false refname: __gsdb_sql_cursor_attri_rowcount__ isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: int4, typoid: 23, ttype: 0, typlen: 4, typrelid: 0, typioparam: 23, collation: 0, typinput_oid: 42, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 8 ispkg: false refname: sqlcode isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: int4, typoid: 23, ttype: 0, typlen: 4, typrelid: 0, typioparam: 23, collation: 0, typinput_oid: 42, atttypmod: -1, typbyval: true, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 9 ispkg: false refname: sqlstate isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: text, typoid: 25, ttype: 0, typlen: -1, typrelid: 0, typioparam: 25, collation: 100, typinput_oid: 46, atttypmod: -1, typbyval: false, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | type: GSPLSQL_DTYPE_VAR, dno: 10 ispkg: false refname: sqlerrm isImplicit: true addNamespace: true pkg_oid: 0 varname: (null) isconst: 0,notnull: 0, isnull: true freeval: false is_place_holder: false isbind: false is_cursor_var: false is_cursor_open: false is_diff_pkg_cursor: false tableOfIndexType: 0 isIndexByTblOf: false | GSPLSQLType: typname: text, typoid: 25, ttype: 0, typlen: -1, typrelid: 0, typioparam: 25, collation: 100, typinput_oid: 46, atttypmod: -1, typbyval: false, typtype: b, typnamespace: pg_catalog, collectionType: 0, tableofOid: 0, tableOfIndexType: 0, arrayTypOid: 0, cursorCompositeOid: 0, subtypOid: 0, is_subtype: false, notnull: false, temptypmod: -1 | default_val: cursor_explicit_expr: | } | datum_need_free:{ 0: true 1: true 2: true 3: true 4: true 5: true 6: true 7: true 8: true 9: true 10: true } | namespace_name: public | glc_status:{m_type: GLC_FUNCTION_OBJ, m_location: in_session, m_glc_object_state: valid, m_refcount: 0} | fn_nargs: 0 | plan_total_mem_size: 30720 | dump count: 1 | ************************************************************************** |