[20241016]Oracle C functions annotations補充.txt

lfree發表於2024-10-16
[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 。


相關文章