oracle - Is this a PL/SQL bug? -
here's excerpt pl/sql code believe demonstrates pl/sql bug:
if guid_ null dbms_output.put_line('guid_ null: ' || guid_); end if;
when these lines executed, prints
guid_ null: 07d242fcc55000fce0530a30d4928a21
i on oracle 11r2
select * v$version; 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 ibm/aix risc system/6000: version 11.2.0.4.0 - production nlsrtl version 11.2.0.4.0 - production
i can reproduce following types , anonymous block. sorry length, believe cannot shorten more:
create type tq84_t table of varchar2(32); / create type tq84_o object ( dummy number(1), not final member procedure clear ) not final; / show errors create type tq84_d under tq84_o ( g varchar2(32), constructor function tq84_d return self result, overriding member procedure clear ); / show errors create package tq84_h t tq84_t; end tq84_h; / show errors create package body tq84_h begin t := tq84_t(); end; / show errors create type body tq84_o member procedure clear begin null; end clear; end; / create type body tq84_d constructor function tq84_d return self result begin g := sys_guid; return; end tq84_d; overriding member procedure clear begin tq84_h.t.extend; tq84_h.t(tq84_h.t.count) := g; g := null; end clear; end; / show errors declare b tq84_o; -- change tq84_d ... guid_ varchar2(32); begin b := new tq84_d; guid_ := treat(b tq84_d).g; b.clear; if guid_ null dbms_output.put_line('guid_ null: ' || guid_); end if; end; / drop type tq84_t; drop type tq84_d; drop type tq84_o; drop package tq84_h;
note also, when change b tq84_o
b tq84_d
, error not occur anymore.
can verify if happening on other systems well?
to me bug. in if
variable guid_
not treated same in the string concatenation put_line
. find strange before b.clear
statement is null
works:
declare b tq84_o; -- change tq84_d ... guid_ varchar2(32); begin b := new tq84_d; guid_ := treat(b tq84_d).g; if guid_ null dbms_output.put_line('before clear: guid_ null: ' || guid_); end if; b.clear; if guid_ null dbms_output.put_line('after clear: guid_ null: ' || guid_); end if; end; /
output:
after clear: guid_ null: 07d43acb728a2173e054a0481c66cf28
i workaround problem when returning guid function:
declare b tq84_o; -- change tq84_d ... guid_ varchar2(32); function get_guid return varchar2 begin return treat(b tq84_d).g; end; begin b := new tq84_d; guid_ := get_guid; -- treat(b tq84_d).g; if guid_ null dbms_output.put_line('before clear: guid_ null: ' || guid_); end if; b.clear; if guid_ null dbms_output.put_line('after clear: guid_ null: ' || guid_); end if; end; /
the above code not go neither of if guid_ null
. me proves it:
this bug.
Comments
Post a Comment