10g sqlplus的一個bug

space6212發表於2019-04-05

今天測試一個儲存過程的時候無意發現了一個10g sqlplus 的bug.


資料庫版本資訊:
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

先建立一個過程,證明許可權是沒問題的:
SQL> create or replace procedure p_test is
2 begin
null;
3 4 end;
5 /

Procedure created.

--開啟autotrace,執行後關閉autotrace
SQL> set autotrace trace
SQL> select 1 from dual;


Execution Plan
----------------------------------------------------------
Plan hash value: 1388734953

-----------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
-----------------------------------------------------------------


Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
508 bytes sent via SQL*Net to client
468 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed

SQL> set autotrace off

--此時再次建立過程會提示許可權不足
SQL> create or replace procedure p_test is
2 begin
3 null;
4 null;
5 end;
6 /
create or replace procedure p_test is
*
ERROR at line 1:
ORA-01031: insufficient privileges

遇到這種情況,只能重新連線,否則執行什麼都會報許可權不足。

--查了一下,後來修改的過程並沒有成功
SQL> select text from user_source where name='P_TEST';

TEXT
--------------------------------------------------------------------------------
procedure p_test is
begin
null;
end;

SQL> show user
USER is "SYS"

簡單總結一下出發這個bug的條件:
1、以sys使用者登入
2、在開啟、並關閉autotrace開關後執行SQL
3、資料庫版本是10g(只在10201測試過)

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

相關文章