plscope-utils icon indicating copy to clipboard operation
plscope-utils copied to clipboard

plscope_tab_usage may return duplicate rows

Open rvo-cs opened this issue 3 years ago • 1 comments
trafficstars

Test setup:

alter session set current_schema = "SCOTT";
alter session set plscope_settings = "IDENTIFIERS:ALL, STATEMENTS:ALL";

create table ta (id number);
create table tb (id number);

create or replace view vwa
as
   select ta.id
     from ta
     join tb
       on ta.id = tb.id;

create or replace view vwb
as
   select tb.id
     from tb
     join vwa
       on tb.id = vwa.id;
       
create or replace package pkg_tst_tab_usage as
   procedure proc;
end pkg_tst_tab_usage;
/

create or replace package body pkg_tst_tab_usage as
   procedure proc is
      l_id number;
   begin
      select v.id into l_id
        from vwb v;
   end proc;
end pkg_tst_tab_usage;
/

Test:

exec plscope_context.set_attr('OWNER', 'SCOTT');
exec plscope_context.set_attr('OBJECT_NAME', 'PKG_TST_TAB_USAGE');

select *
  from plscope.plscope_tab_usage
 order by line,
       col,
       ref_object_type,
       ref_object_name;

Actual result set:

OWNER    OBJECT_TYPE     OBJECT_NAME          LINE    COL    PROCEDURE_NAME    OPERATION    REF_OWNER    REF_OBJECT_TYPE    REF_OBJECT_NAME    DIRECT_DEPENDENCY    TEXT                   
SCOTT    PACKAGE BODY    PKG_TST_TAB_USAGE          6     14 PROC              SELECT       SCOTT        TABLE              TA                 NO                           from vwb v;    
SCOTT    PACKAGE BODY    PKG_TST_TAB_USAGE          6     14 PROC              SELECT       SCOTT        TABLE              TB                 NO                           from vwb v;    
SCOTT    PACKAGE BODY    PKG_TST_TAB_USAGE          6     14 PROC              SELECT       SCOTT        TABLE              TB                 NO                           from vwb v;    
SCOTT    PACKAGE BODY    PKG_TST_TAB_USAGE          6     14 PROC              SELECT       SCOTT        VIEW               VWA                NO                           from vwb v;    
SCOTT    PACKAGE BODY    PKG_TST_TAB_USAGE          6     14 PROC              SELECT       SCOTT        VIEW               VWB                YES                          from vwb v;    

Table TB, at line 6, column 14, appears twice.

Expected result set: same as above, except that the duplicate row for table TB at line 6, column 14, should be removed.

rvo-cs avatar Nov 04 '22 23:11 rvo-cs

Thank you for reporting this issue. This looks like a bug.

PhilippSalvisberg avatar Nov 05 '22 14:11 PhilippSalvisberg