Tracing Oracle Internal Calls - Trace Sqlplus

westzq1984發表於2010-10-28
新增一點,跟蹤SQLPLUS等ORACLE客戶端執行了那些SQL語句

相當於TOAD的sqlmonitor功能

[oracle10@zhangqiaoc ~]$ ps -ef|grep sqlplus

oracle10   460   412  0 13:35 pts/1    00:00:00 sqlplus          

oracle10   841   368  0 13:50 pts/2    00:00:00 grep sqlplus

[oracle10@zhangqiaoc ~]$ gdb -p 460

(gdb) set height 0

(gdb) b kpursetstmttext

Breakpoint 1 at 0xd7debe

(gdb) while (1<2)

 >x /s *(unsigned int *)($ebp+12)

 >c

 >end

0xb7f29000:      ""

--[SQLPLUS]------------------------------------------------------

SQL> DECLARE

  2    lvc_sql VARCHAR2(1000);       

  3  BEGIN

  4    FOR i IN 1..100 LOOP

  5      lvc_sql := 'INSERT INTO test VALUES('||i||')';

  6      EXECUTE IMMEDIATE lvc_sql;

  7    END LOOP;

  8  END;

  9  /

PL/SQL procedure successfully completed.

-----------------------------------------------------------------

[Switching to Thread 16384 (LWP 913)]

Breakpoint 1, 0x00ee1ebe in kpursetstmttext ()

   from /oracle10/product/10.2/lib/libclntsh.so.10.1

0x80e21f8:       "DECLARE\n  lvc_sql VARCHAR2(1000);\nBEGIN\n  FOR i IN 1..100 LOOP\n    lvc_sql := 'INSERT INTO test VALUES('||i||')';\n    EXECUTE IMMEDIATE lvc_sql;\n  END LOOP;\nEND;"


只測試了SQLPLUS,如果是OCI等連線,可以gdb進去後info func得到方法列表,然後找出可能的FUNC測試下,可能是OCIStmtPrepare

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8242091/viewspace-676975/,如需轉載,請註明出處,否則將追究法律責任。

相關文章