Dec 18: Bug Hunting
SQL> CREATE TYPE INTEGER_ARRAY_T AS TABLE OF INTEGER
2 /
Type created.
SQL>
SQL> CREATE TABLE V_SESSION_VALID (
2 SID NUMBER ,
3 SESSION_ID NUMBER NOT NULL,
4 CONSTRAINT SID_PK PRIMARY KEY (SID) VALIDATE ,
5 CONSTRAINT SESSIONID_UK UNIQUE (SESSION_ID) VALIDATE)
6 /
Table created.
SQL>
SQL> CREATE TABLE SESSION_VIEW ( VIEW_ID NUMBER ,
2 SESSION_ID NUMBER NOT NULL,
3 ROW_COUNT NUMBER NOT NULL,
4 CONSTRAINT VIEWID_PK PRIMARY KEY (VIEW_ID) VALIDATE)
5 /
Table created.
SQL>
SQL> CREATE TABLE BATCH_SESSION (BATCH_ID NUMBER NOT NULL , ROW_ID NUMBER NOT NULL ,
SID NUMBER NOT NULL )
2 /
Table created.
SQL>
SQL> declare
2 l_sessions INTEGER_ARRAY_T;
3 begin
4 select s.SESSION_ID
5 bulk collect into l_sessions
6 from V_SESSION_VALID s
7 join SESSION_VIEW v on (s.SESSION_ID = v.SESSION_ID)
8 join BATCH_SESSION b on (s.SID = b.SID)
9 where v.ROW_COUNT > 0
10 and b.BATCH_ID between 1 and 1000
11 for update of s.SESSION_ID;
12 end;
13 /
select s.SESSION_ID
*
ERROR at line 4:
ORA-06550: line 4, column 2:
PL/SQL: ORA-00918: column ambiguously defined
ORA-06550: line 4, column 2:
PL/SQL: SQL Statement ignored
This works in all versions prior to 11.2.0.1, which is where it was identified during some 11gR2 RAC testing of the application I'm working on. There are actually quite a few notes about this type of error kicking around on My Oracle Support, but in most cases they aren't bugs, but a tightening of ambiguous column checking, which is a good thing. However, if your app does use ANSI join syntax, keep an eye out for 11gR2 catching out previously suspect SQL statements when you're upgrading.
However, there is no ambiguous column definition here. If I convert it to traditional Oracle join syntax, it works, as does commenting out the offending part of the code.
SQL> declare 2 l_sessions INTEGER_ARRAY_T; 3 begin 4 select s.SESSION_ID 5 bulk collect into l_sessions 6 from V_SESSION_VALID s 7 join SESSION_VIEW v on (s.SESSION_ID = v.SESSION_ID) 8 join BATCH_SESSION b on (s.SID = b.SID) 9 where v.ROW_COUNT > 0 10 and b.BATCH_ID between 1 and 1000; 11 -- for update of s.SESSION_ID; 12 end; 13 / PL/SQL procedure successfully completed.
So why do I say joint father of the bug report? Because having raised the SR, we delayed our 11gR2 upgrade work for unassociated reasons and so I didn't put the work in to provide the proper test case that Oracle Support requested. A couple of weeks later, with the SR abandoned for now, one of the DBAs mentioned a bug he'd found on 11gR2 and my first question was 'ANSI join syntax?'. Sure enough, it was the same as our example so he picked up the SR and ran with it and put together the test case here, which is also stripped of any company information. So we might have hit it first, but Cristian Banoiu put in the hard work. I'm sure he was pretty proud when it was assigned a bug number and I believe it's currently in development.
#1 - Dominic Brooks said:
2009-12-19 08:34 - (Reply)
So the moral of the story is don't use the ANSI join syntax? ![]()
#1.1 - Doug Burns said:
2009-12-19 09:42 - (Reply)
![]()
I almost made that point but then I was conscious that I didn't want to write something that might cause people to avoid it forever! Having posted about what I like about ANSI join syntax in the past, though, the single biggest reason I don't use it is I've run out of the number of related bugs I've seen mentioned in release notes!
#1.1.1 - Tom Underhill 2010-01-08 10:47 - (Reply)
here's another 11.2 one for you which I discovered yesterday
drop table table1;
drop table table2;
create table table1 ( id number, text1 varchar2(30),text2 varchar(30) );
create table table2 ( id number, text1 varchar2(30),text2 varchar(30) );
SELECT table1.rowid
FROM table1
JOIN table2 t2 ON table1.id = t2.id
FOR UPDATE OF table1.text1,table1.text2;
This query will hang for infinity and cause the cpu to go through the roof, it won't respond to cntl-c and you have to kill the server process. It only occues if you're using ansi join syntax and more than 1 column in the FOR UPDATE OF clause - workaround ? you guessed it - don't use ansi join syntax. I'm now an expectant father of an oracle bug !
#1.1.1.1 - Doug Burns said:
2010-01-09 10:41 - (Reply)
Cool - thanks.
I feel a new acronym coming on - YAAJSB.
Yet another ANSI Join Syntax bug ![]()
#2 - Doug Burns said:
2010-02-12 08:51 - (Reply)
UPDATE: Confirmed as a bug and fixed in 11.2.0.2
#2.1.1 - Doug Burns said:
2010-02-24 06:15 - (Reply)
As stated in the post above, it's bug number 9219636. Confirmed by just looking it up. If you can't see it perhaps it's some MOS issue
https://support.oracle.com/CSP/main/article?cmd=show&type=BUG&id=9219636&productFamily=Oracle
#3 - Doug Burns said:
2010-04-16 04:46 - (Reply)
One-off patch 9219636 has now been published for this.

Tracked: Jan 02, 17:50