Skip to Main Content
  • Questions
  • Error running sql on Oracle 19c table subpartitioned by list

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Alexandru.

Asked: July 16, 2020 - 10:13 am UTC

Last updated: July 16, 2020 - 5:23 pm UTC

Version: 19.0.0.0.0

Viewed 1000+ times

You Asked

Hi Tom,

We have found the following problem in Oracle 19c. We have a table subpartitioned by list that has more than 2 values as partitioning keys:

create table T19c 
( 
    Filed1 varchar2(50), 
    Filed2 varchar2(50), 
    Filed3 varchar2(50), 
    Filed4 varchar2(50) 
) 
partition by list(Filed1) 
subpartition by list(Filed2, Filed3, Filed4) 
subpartition template 
( 
    SUBPARTITION S_A_A_A VALUES ('A1','A1','A1') 
    ,SUBPARTITION S_A_A_B values('A1','A1','B1') 
    ,SUBPARTITION S_A_A_C values('A1','A1','C1') 
    ,SUBPARTITION S_A_A_D values('A1','A1','D1') 

) 
( 
    PARTITION P_TST1 VALUES ('TST1') 
);


Let's say we have inserted the following values in the table:

INSERT INTO T19c VALUES ('TST1', 'A1', 'A1', 'A1');
INSERT INTO T19c VALUES ('TST1', 'A1', 'A1', 'B1');
INSERT INTO T19c VALUES ('TST1', 'A1', 'A1', 'C1');
INSERT INTO T19c VALUES ('TST1', 'A1', 'A1', 'D1');


The problem is that when you run the below query, it returns wrong results:

select * from T19c where Filed4 <> 'A1';


Instead of returning the rows that have values for vchcol4 <> 'A', it returns "no data found". We have noticed that this problem does not persist if the subpartitions are created with 2 values as partitioning keys.

Is there any way to fix this without having to change the subpartitioning logic?

Thanks,
Alex

with LiveSQL Test Case:

and Chris said...

That's... not right!

Contact support to get a fix for this.

In the meantime I think you'll have to change the logic - I can't see another workaround at this stage.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

with expressions

Rajeshwaran, Jeyabal, July 16, 2020 - 3:16 pm UTC

sounds like a bug, but the following works.
demo@PDB1> select filed4,dump(filed4) as dump from t19c;

FILED DUMP
----- ------------------------------
A1    Typ=1 Len=2: 65,49
B1    Typ=1 Len=2: 66,49
C1    Typ=1 Len=2: 67,49
D1    Typ=1 Len=2: 68,49

demo@PDB1> select filed4 from T19c where filed4 <> 'A1';

no rows selected

demo@PDB1> select filed4 from T19c where filed4||'' <> 'A1';

FILED
-----
B1
C1
D1

Chris Saxon
July 16, 2020 - 5:23 pm UTC

Nice investigation.

Subpartitions syntax

Iudith Mentzel, July 17, 2020 - 4:38 am UTC

Hello All,

When specifying "n" partitioning keys for a list (sub)partition, I think that the correct syntax is supposed to contain lists of "n"-uples, instead of single values, like this:

create table T19c
(
Filed1 varchar2(50),
Filed2 varchar2(50),
Filed3 varchar2(50),
Filed4 varchar2(50)
)
partition by list(Filed1)
subpartition by list(Filed2, Filed3, Filed4)
subpartition template
(
SUBPARTITION S_A_A_A VALUES ( ('A1','A1','A1') )
,SUBPARTITION S_A_A_B values( ('A1','A1','B1') )
,SUBPARTITION S_A_A_C values( ('A1','A1','C1') )
,SUBPARTITION S_A_A_D values( ('A1','A1','D1') )

)
(
PARTITION P_TST1 VALUES ('TST1')
);


This does NOT change the wrong result, though ...

Cheers & Best Regards,
Iudith Mentzel

More to Explore

VLDB

If you are new to partitioning, check out Connor McDonald's introduction series here.

VLDB

Documentation set on VLDB and Partitioning.