I found this after upgrading from Oracle 11g Release 1 to Release 2.
The best I can summarize now is that LEFT OUTER JOIN against a query with a constant "fake" column and a WHERE generates different results in two Oracle RELEASES. In Release 2, the “fake” column appears in unmatched rows:
TEST1 TEST2 ===== ===== ABAB -
So far so good. all of the above works on Rel. 1 and 2. Now add the constant column “fake” X, and everything will work as expected:
> SELECT * FROM test1 LEFT OUTER JOIN (SELECT test2.*, 'X' AS X FROM test2) test3 ON test1.a = test3.a; AB A_1 B_1 X - --- --- ----- - 1 bar 1 hello X 2 baz
Now add the WHERE to the first table and get different results:
> SELECT * FROM test1 LEFT OUTER JOIN (SELECT test2.*, 'X' AS X FROM test2) test3 ON test1.a = test3.a WHERE test1.b LIKE 'ba%'; Release 11.1.0.7.0 Release 11.2.0.2.0 ================== ================== AB A_1 B_1 XAB A_1 B_1 X - --- --- ----- - - --- --- ----- - 1 bar 1 hello X 1 bar 1 hello X 2 baz 2 baz X <--- WHAT THIS?!
Further puzzling: if the WHERE condition is numeric (for example, WHERE test1.a < 5 , the results are the same!
UPDATE (to clarify my actual question): What am I doing wrong? Is my last request somehow invoking undefined behavior, which makes it right for Oracle to change what was returned from one version to another? If not, is this an Oracle error?
Arkady
source share