handle parse fail

SQL> select * from v$version;


BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production


对sys账号无效


1.event 10035
ALTER SYSTEM SET EVENTS '10035 trace name context forever, level 1';


sqlplus执行: select * fromaaa;


alert:


PARSE ERROR: ospid=31855, error=923 for statement:
select * fromaaaa^@
Additional information: hd=0x8a91b2c0 phd=0x8a86fb28 flg=0x28 cisid=42 sid=42 ciuid=42 uid=42




2.workaround


alter system set "_cursor_features_enabled" = 34 scope=spfile;
(restart instance)


sqlplus执行: select * fromaaa;


信息存入SQLERROR$,后面再执行同样的sql就不会parse了:
select * from SQLERROR$;
SQLHASH                                                              ERROR#    ERRPOS#      FLAGS     SPARE1     SPARE2     SPARE3
---------------------------------------------------------------- ---------- ---------- ---------- ---------- ---------- ----------
677ebfb9892fecc7a9f5258be8fe30a                                         923          9          0          0          0          0




注意:只有语法错的sql才会存入SQLERROR$


这个sqlhash:677ebfb9892fecc7a9f5258be8fe30a 就是x$kglob.KGLNAHSV


用python验证一下:


[root@inforsrv ~]# python
Python 2.6.6 (r266:84292, Jun 18 2012, 09:14:33) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> import math
>>> import struct
>>> stmt = "select * fromaaa"
>>> d = hashlib.md5(stmt + '\x00').digest()
>>> h = ''
>>> for i in struct.unpack('IIII', d): h += hex(i)[2:]
... 
>>> h
'677ebfb9892fecc7a9f5258be8fe30a'
>>> 




注意:
1.如果python版本太低,没有hashlib. 
2.需要在sql后加行结束符(\0)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/37279/viewspace-1873886/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/37279/viewspace-1873886/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值