# 障害票1051
# single/normal/21132

Begin;
Initialize;
InitializeSession "";

Command "create table T(c char(8) array[2])";

Command "insert T values (null)";
Command "insert T values (array[null])";
Command "insert T values (array[''])";
Command "insert T values (array['abc'])";
Command "insert T values (array[' abc'])";
Command "insert T values (array['abc '])";
Command "insert T values (array[' abc '])";
Command "insert T values (array[null, null])";
Command "insert T values (array[null, 'def'])";
Command "insert T values (array['ghi', null])";
Command "insert T values (array['jkl', 'mno'])";

Command "create bitmap index I on T(c) hint 'compressed'";

Command "insert T values (null)";
Command "insert T values (array[null])";
Command "insert T values (array[''])";
Command "insert T values (array['abc'])";
Command "insert T values (array[' abc'])";
Command "insert T values (array['abc '])";
Command "insert T values (array[' abc '])";
Command "insert T values (array[null, null])";
Command "insert T values (array[null, 'def'])";
Command "insert T values (array['ghi', null])";
Command "insert T values (array['jkl', 'mno'])";

Command "select * from T where c[] = null";
Command "select * from T where c[] = ''";
Command "select * from T where c[] = 'abc'";
Command "select * from T where c[] = 'xyz'";
Command "select * from T where c[] > null";
Command "select * from T where c[] > ''";
Command "select * from T where c[] > 'abc'";
Command "select * from T where c[] > 'xyz'";
Command "select * from T where c[] >= null";
Command "select * from T where c[] >= ''";
Command "select * from T where c[] >= 'abc'";
Command "select * from T where c[] >= 'xyz'";
Command "select * from T where c[] < null";
Command "select * from T where c[] < ''";
Command "select * from T where c[] < 'abc'";
Command "select * from T where c[] < 'xyz'";
Command "select * from T where c[] <= null";
Command "select * from T where c[] <= ''";
Command "select * from T where c[] <= 'abc'";
Command "select * from T where c[] <= 'xyz'";
Command "select * from T where c[] like null";
Command "select * from T where c[] like ''";
Command "select * from T where c[] like 'abc'";
Command "select * from T where c[] like 'ab%'";
Command "select * from T where c[] like 'a%c'";
Command "select * from T where c[] like 'xyz'";
# Command "select * from T where c[] like '%bc'";
Command "select * from T where c[] like 'ab_'";
Command "select * from T where c[] like 'a_c'";
# Command "select * from T where c[] like '_bc'";
# Command "select * from T where c[] like '%b%'";
Command "select * from T where c[] between null and null";
Command "select * from T where c[] between '' and null";
Command "select * from T where c[] between 'abc' and null";
Command "select * from T where c[] between 'xyz' and null";
Command "select * from T where c[] between null and ''";
Command "select * from T where c[] between '' and ''";
Command "select * from T where c[] between 'abc' and ''";
Command "select * from T where c[] between 'xyz' and ''";
Command "select * from T where c[] between null and 'abc'";
Command "select * from T where c[] between '' and 'abc'";
Command "select * from T where c[] between 'abc' and 'abc'";
Command "select * from T where c[] between 'xyz' and 'abc'";
Command "select * from T where c[] between null and 'xyz'";
Command "select * from T where c[] between '' and 'xyz'";
Command "select * from T where c[] between 'abc' and 'xyz'";
Command "select * from T where c[] between 'xyz' and 'xyz'";
Command "select * from T where c[] is null";
Command "select * from T where c[] is not null";
Command "select * from T where c is null";
Command "select * from T where c is not null";
Command "select * from T where c[] = null or c[] = 'abc'";
Command "select * from T where c[] = '' or c[] = 'abc'";
Command "select * from T where c[] = 'abc' or c[] = 'abc'";

# update to same data
Command "update T set c = (null) where c is null";
Command "select * from T";
Command "update T set c = (array['']) where c[] = ''";
Command "select * from T";
Command "update T set c = (array['jkl', 'mno']) where c[] = 'jkl'";
Command "select * from T";

# update to the data in the another tree
Command "update T set c = (array['na->d']) where c is null";
Command "select * from T";
Command "update T set c = (null) where c[] = 'na->d'";
Command "select * from T";
Command "update T set c = (array[null]) where c[] = ''";
Command "select * from T";
Command "update T set c = (array['']) where c[] is null";
Command "select * from T";
Command "update T set c = (array[null]) where c is null";
Command "select * from T";
Command "update T set c = (null) where c[] is null";
Command "select * from T";

# update to the data which have the different number of array fields in the same tree.
Command "update T set c = (array['a1a2->a1']) where c[] = 'jkl'";
Command "select * from T";
Command "update T set c = (array['jkl', 'mno']) where c[] = 'a1a2->a1'";
Command "select * from T";
Command "update T set c = (array[null]) where c[] = ''";
Command "select * from T";
Command "update T set c = (array[null, null]) where c[] is null";
Command "select * from T";
Command "update T set c = (array[null]) where c[] is null";
Command "select * from T";

# update to the data which have the different number of array fields in the another tree.
Command "update T set c = (null) where c[] = 'jkl'";
Command "select * from T";
Command "update T set c = (array['jkl', 'mno']) where c is null";
Command "select * from T";
Command "update T set c = (array[null, null]) where c[] is null";
Command "select * from T";
Command "update T set c = (null) where c[] is null";
Command "select * from T";
Command "update T set c = (array[null, null]) where c is null";
Command "select * from T";

# update to the conbination data which have null data and not null data.
Command "update T set c = (array['jkl',null]) where c[] = 'jkl'";
Command "select * from T";
Command "update T set c = (array[null, 'jkl']) where c[] = 'jkl'";
Command "select * from T";

Command "verify table T cascade continue";

Command "delete from T where c is null";
Command "select * from T";
Command "delete from T where c[] is null";
Command "select * from T";
Command "delete from T where c[] >= ''";
Command "select * from T";

Command "verify table T cascade continue";

Command "drop table T";

TerminateSession;
Terminate;
End;

