[20241016]Oracle C functions annotations补充.txt

[20241016]Oracle C functions annotations补充.txt

--//网站orafun.info可以查询oracle c functions.Created by Frits Hoogland with a little help from Kamil Stawiarski.
--//可以通过它了解oracle 内部C 函数.实际上可以直接下载相关文件,在本地使用.

https://gitlab.com/FritsHoogland/ora_functions/archive/master/ora_functions-master.tar.gz
https://gitlab.com/FritsHoogland/ora_functions

$ ll
total 12828
-rwxrwxr-x. 1 oracle oinstall     1035 2021-01-29 22:06:05 annotate_flamegraph.awk
-rwxrwxr-x. 1 oracle oinstall     2439 2021-01-29 22:06:05 fold_debugtrace.awk
-rw-rw-r--. 1 oracle oinstall   348445 2021-01-29 22:06:05 functions.csv
-rw-r--r--. 1 oracle oinstall   418816 2024-10-16 09:50:45 functions.db
-rwxrwxr-x. 1 oracle oinstall     1630 2021-01-29 22:06:05 lookup.awk
-rwxr-xr-x. 1 oracle oinstall     1660 2024-10-16 09:58:54 lookupx.awk
-rw-rw-r--. 1 oracle oinstall     1679 2021-01-29 22:06:05 readme.md
-rwxrwxr-x. 1 oracle oinstall     3474 2021-01-29 22:06:05 sf.sh
-rw-rw-r--. 1 oracle oinstall 12231272 2021-01-29 22:06:05 symbol_archive_object_19.9.csv
-rw-rw-r--. 1 oracle oinstall    32650 2021-01-29 22:06:05 v_tables_x_tables_mapping.csv
-rw-rw-r--. 1 oracle oinstall    66350 2021-01-29 22:06:05 x_tables_descriptions.csv

--//实际上还有1个sf.sh脚本,它需要本机安装sqlite3。
$ grep ^sqlite3 sf.sh
sqlite3 functions.db "drop table if exists functions;"
sqlite3 functions.db "create table functions (function_name varchar(30), function_sum varchar(60));"
sqlite3 functions.db ".import functions.csv functions"

--//手工执行它后可以建立建立导入表functions。functions.db就是执行脚本sf.sh后建立的文件。
--//注意:你执行完1次后,可以注解前面的这3行.

$ ./sf.sh kgllkal
kgllkal -- kernel generic library cache management library cache lock allocate
-------

--//不过显示与lookup.awk不同。
$ ./lookup.awk -w   kglpn
kglpn : kernel generic library cache management pin
kglpnal : kernel generic library cache management pin allocate
kglpnc : kernel generic library cache management pin pin heaps and load data pieces of a cursor object
kglpnck : kernel generic library cache management pin pin heaps and load data pieces of a cursor object check if latch is held
kglpndl : kernel generic library cache management pin delete data heaps
kglpnds : kernel generic library cache management pin delete state object
kglpnmi : kernel generic library cache management pin migration
kglpnp : kernel generic library cache management pin pin heaps and load data for stored procedures

$ ./sf.sh -w   kglpn
kglpn   pin
kglpnal allocate
kglpnc  pin heaps and load data pieces of a cursor object
kglpnck check if latch is held
kglpndl delete data heaps
kglpnds delete state object
kglpnmi migration
kglpnp  pin heaps and load data for stored procedures

--//还有2个文件。
$ ll *table*
-rw-rw-r--. 1 oracle oinstall 32650 2021-01-29 22:06:05 v_tables_x_tables_mapping.csv
-rw-rw-r--. 1 oracle oinstall 66350 2021-01-29 22:06:05 x_tables_descriptions.csv

--//可以直接使用grep查询:

$ grep -i kglob x_tables_descriptions.csv
X$KGLOB|kernel generic library cache object
X$KGLOBXML|kernel generic library cache object xml (version of x$kglob)
--//oracle 的X表都是大写。加入-i或者直接大写。

$ grep -i 'x$kglob' x_tables_descriptions.csv
X$KGLOB|kernel generic library cache object
X$KGLOBXML|kernel generic library cache object xml (version of x$kglob)
--//如果查询带有$字符,要加入单引号。

--//也可以修改lookup.awk文件,修改文件名实现查询。
$ diff -Nur lookup.awk lookupx.awk
--- lookup.awk  2021-01-29 22:06:05.000000000 +0800
+++ lookupx.awk 2024-10-16 09:58:54.461069120 +0800
@@ -33,14 +33,14 @@
     exit 1
   }
   if ( ARGV[1] == "-w" ) {
-    requested_function = ARGV[2];
+    requested_function = toupper(ARGV[2]);
   } else {
-    requested_function = ARGV[1];
+    requested_function = toupper(ARGV[1]);
   }
   # load functions from csv into array
   PROCINFO["sorted_in"] = "@ind_str_asc";
   FS="|";
-  while ( ( getline < "functions.csv" ) > 0 ) function_array[$1]=$2;
+  while ( ( getline < "x_tables_descriptions.csv" ) > 0 ) function_array[$1]=$2;
   # lookup function annotation starting with <function>
   if ( ARGV[1] == "-w" ) {
     for ( function_from_array in function_array )

$ ./lookupx.awk   'x$kglob'
X$KGLOB : kernel generic library cache object
--//这个的查询特点一定要带单引号,还是grep方便。

$ grep -i alert x_tables_descriptions.csv
X$DBGALERTEXT|debug alert extended information
X$DIAG_ALERT_EXT|diagnostics alert extended. database alert log details
X$KELRSGA|kernel event alert SGA
X$KELRTD|kernel event alert threshold type descriptions
X$KELTGSD|kernel event alert types generator descriptions
X$KELTOSD|kernel event alert types operations descriptions
X$KELTSD|kernel event alert types descriptions
X$KXDCM_OPEN_ALERTS|kernel execution exadata cell metrics open alerts

--//查询v_tables_x_tables_mapping.csv可以知道一些对应关系,不过好像不全。
$ grep -i ir_failure v_tables_x_tables_mapping.csv
GV$IR_FAILURE|X$DBKFDG
GV$IR_FAILURE_SET|X$DBKFSET

$ grep -i '^GV$SESSION|' v_tables_x_tables_mapping.csv
GV$SESSION|X$KSUSE
--//仅仅看到1个X表,实际上关联 x$ksuse , x$ksled , x$kslwt 。