Begin;

SetSystemParameter "Plan_TraceOptimizationOutput" "1";
SetSystemParameter "Plan_TraceLevel" "2";

Initialize;
InitializeSession "TESTDB";
Command "create database TESTDB";
TerminateSession;
InitializeSession "TESTDB";
#
# ALL ROWS INDEX -- null値も格納するBtree索引のテスト -- order byと検索条件 : 非複合索引
#

Command "create table T(c1 char(4), c2 nchar(4), c3 varchar(4), c4 nvarchar(4), c5 varchar(4) hint nontruncate, c6 nvarchar(4) hint nontruncate, c7 int, c8 bigint, c9 float, c10 datetime, c11 language, c12 decimal(2,0), c1_ar char(4), c2_ar nchar(4), c3_ar varchar(4), c4_ar nvarchar(4), c5_ar varchar(4) hint nontruncate, c6_ar nvarchar(4) hint nontruncate, c7_ar int, c8_ar bigint, c9_ar float, c10_ar datetime, c11_ar language, c12_ar decimal(2,0))";
Command "insert into T values((null), 'あいう', 'abx', (null), 'abx', 'abx', (null), 847865165, 3.141592, (null), 'ja', -1, (null), 'あいう', 'abx', (null), 'abx', 'abx', (null), 847865165, 3.141592, (null), 'ja', -1)";
Command "insert into T values((null), (null), 'aby', 'あいう', (null), 'aby', 123, (null), 1.414213, '2007-01-01 12:34:56.789', (null), 1, (null), (null), 'aby', 'あいう', (null), 'aby', 123, (null), 1.414213, '2007-01-01 12:34:56.789', (null), 1)";
Command "insert into T values((null), 'あえう', (null), 'あえう', 'aby', (null), 456, 123456789, (null), '2007-02-01 12:34:56.789', 'zh', (null), (null), 'あえう', (null), 'あえう', 'aby', (null), 456, 123456789, (null), '2007-02-01 12:34:56.789', 'zh', (null))";
Command "insert into T values('abx', 'あいう', 'aby', 'あえう', 'abx', 'aby', 456, 847865165, 1.414213, '2007-02-01 12:34:56.789', 'ja', 1, 'abx', 'あいう', 'aby', 'あえう', 'abx', 'aby', 456, 847865165, 1.414213, '2007-02-01 12:34:56.789', 'ja', 1)";
Command "insert into T values('abx', (null), 'abx', (null), 'aby', (null), 123, (null), 3.141592, (null), 'zh', (null), 'abx', (null), 'abx', (null), 'aby', (null), 123, (null), 3.141592, (null), 'zh', (null))";
Command "insert into T values('abx', 'あえう', 'abx', 'あいう', (null), 'abx', (null), 123456789, (null), '2007-01-01 12:34:56.789', (null), -1, 'abx', 'あえう', 'abx', 'あいう', (null), 'abx', (null), 123456789, (null), '2007-01-01 12:34:56.789', (null), -1)";
Command "insert into T values('aby', 'あいう', (null), 'あいう', 'aby', 'abx', 123, 847865165, 1.414213, '2007-01-01 12:34:56.789', 'zh', (null), 'aby', 'あいう', (null), 'あいう', 'aby', 'abx', 123, 847865165, 1.414213, '2007-01-01 12:34:56.789', 'zh', (null))";
Command "insert into T values('aby', (null), 'aby', (null), 'abx', (null), (null), 123456789, (null), '2007-02-01 12:34:56.789', (null), 1, 'aby', (null), 'aby', (null), 'abx', (null), (null), 123456789, (null), '2007-02-01 12:34:56.789', (null), 1)";
Command "insert into T values('aby', 'あえう', (null), 'あえう', (null), 'aby', (null), (null), 3.141592, (null), 'ja', -1, 'aby', 'あえう', (null), 'あえう', (null), 'aby', (null), (null), 3.141592, (null), 'ja', -1)";
Command "insert into T values('aby', (null), 'abx', 'あいう', 'abx', (null), 456, 847865165, 3.141592, '2007-01-01 12:34:56.789', 'ja', -1, 'aby', (null), 'abx', 'あいう', 'abx', (null), 456, 847865165, 3.141592, '2007-01-01 12:34:56.789', 'ja', -1)";
Command "insert into T values('abx', 'あえう', 'aby', (null), (null), 'abx', 123, 847865165, (null), (null), 'zh', 1, 'abx', 'あえう', 'aby', (null), (null), 'abx', 123, 847865165, (null), (null), 'zh', 1)";
Command "insert into T values('abx', 'あいう', (null), (null), (null), 'aby', 456, 123456789, 3.141592, '2007-02-01 12:34:56.789', (null), (null), 'abx', 'あいう', (null), (null), (null), 'aby', 456, 123456789, 3.141592, '2007-02-01 12:34:56.789', (null), (null))";
Command "insert into T values((null), 'あいう', 'abx', 'あえう', 'aby', 'abx', 123, 123456789, 1.414213, '2007-02-01 12:34:56.789', 'ja', -1, (null), 'あいう', 'abx', 'あえう', 'aby', 'abx', 123, 123456789, 1.414213, '2007-02-01 12:34:56.789', 'ja', -1)";
Command "insert into T values((null), (null), (null), 'あえう', 'abx', 'abx', (null), (null), (null), '2007-01-01 12:34:56.789', 'zh', (null), (null), (null), (null), 'あえう', 'abx', 'abx', (null), (null), (null), '2007-01-01 12:34:56.789', 'zh', (null))";
Command "insert into T values((null), 'あいう', 'aby', (null), 'aby', 'aby', (null), (null), (null), (null), (null), -1, (null), 'あいう', 'aby', (null), 'aby', 'aby', (null), (null), (null), (null), (null), -1)";
Command "insert into T values('abx', 'あえう', 'abx', (null), 'abx', 'aby', 456, (null), 1.414213, (null), 'zh', 1, 'abx', 'あえう', 'abx', (null), 'abx', 'aby', 456, (null), 1.414213, (null), 'zh', 1)";
Command "insert into T values('aby', 'あいう', 'aby', 'あいう', 'aby', (null), (null), 123456789, 3.141592, (null), 'zh', 1, 'aby', 'あいう', 'aby', 'あいう', 'aby', (null), (null), 123456789, 3.141592, (null), 'zh', 1)";
Command "insert into T values('aby', 'あえう', (null), 'あいう', (null), (null), (null), 847865165, 1.414213, '2007-02-01 12:34:56.789', (null), 1, 'aby', 'あえう', (null), 'あいう', (null), (null), (null), 847865165, 1.414213, '2007-02-01 12:34:56.789', (null), 1)";
Command "insert into T values('abx', (null), 'aby', 'あえう', 'abx', 'abx', 456, (null), (null), '2007-02-01 12:34:56.789', 'ja', (null), 'abx', (null), 'aby', 'あえう', 'abx', 'abx', 456, (null), (null), '2007-02-01 12:34:56.789', 'ja', (null))";
Command "insert into T values((null), 'あえう', 'abx', 'あえう', 'abx', (null), 123, 847865165, 3.141592, '2007-01-01 12:34:56.789', (null), 1, (null), 'あえう', 'abx', 'あえう', 'abx', (null), 123, 847865165, 3.141592, '2007-01-01 12:34:56.789', (null), 1)";
Command "insert into T values('abx', (null), (null), (null), 'aby', 'aby', 123, 123456789, 1.414213, '2007-01-01 12:34:56.789', 'zh', -1, 'abx', (null), (null), (null), 'aby', 'aby', 123, 123456789, 1.414213, '2007-01-01 12:34:56.789', 'zh', -1)";

## index
Command "create index I on T(c4)";
Command "select c4 from T where c4 is null order by c4 asc";
Command "drop index I";
Command "create index I on T(c7)";
Command "select c7 from T where c7 < 456 order by c7 desc";
Command "drop index I";
Command "create index I on T(c3)";
Command "select c3 from T where c3 like 'ab%'";
Command "drop index I";
Command "create index I on T(c8)";
Command "select c8 from T where c8 = 847865165 order by c8 desc";
Command "drop index I";
Command "create index I on T(c9)";
Command "select c9 from T where c9 = 1.414213";
Command "drop index I";
Command "create index I on T(c6)";
Command "select c6 from T where c6 <> 'aby' order by c6 desc";
Command "drop index I";
Command "create index I on T(c2)";
Command "select c2 from T where c2 is null";
Command "drop index I";
Command "create index I on T(c12)";
Command "select c12 from T where c12 is null order by c12 desc";
Command "drop index I";
Command "create index I on T(c3)";
Command "select c3 from T";
Command "drop index I";
Command "create index I on T(c1)";
Command "select c1 from T where c1 = 'aby' order by c1 asc";
Command "drop index I";
Command "create index I on T(c1)";
Command "select c1 from T where c1 is null";
Command "drop index I";
Command "create index I on T(c7)";
Command "select c7 from T where c7 = 123";
Command "drop index I";
Command "create index I on T(c5)";
Command "select c5 from T where c5 like 'ab%' order by c5 asc";
Command "drop index I";
Command "create index I on T(c8)";
Command "select c8 from T where c8 is null order by c8 asc";
Command "drop index I";
Command "create index I on T(c5)";
Command "select c5 from T where c5 <= 'abx'";
Command "drop index I";
Command "create index I on T(c1)";
Command "select c1 from T where c1 <> 'aby' order by c1 desc";
Command "drop index I";
Command "create index I on T(c4)";
Command "select c4 from T where c4 < 'あえう'";
Command "drop index I";
Command "create index I on T(c10)";
Command "select c10 from T where c10 > '2007-02-01 12:34:56.789' order by c10 asc";
Command "drop index I";
Command "create index I on T(c12)";
Command "select c12 from T where c12 >= 1 order by c12 asc";
Command "drop index I";
Command "create index I on T(c8)";
Command "select c8 from T where c8 = 847865165 order by c8 asc";
Command "drop index I";
Command "create index I on T(c6)";
Command "select c6 from T where c6 = 'aby' order by c6 asc";
Command "drop index I";
Command "create index I on T(c4)";
Command "select c4 from T where c4 is null order by c4 desc";
Command "drop index I";
Command "create index I on T(c3)";
Command "select c3 from T where c3 like 'ab%'";
Command "drop index I";
Command "create index I on T(c1)";
Command "select c1 from T where c1 is null";
Command "drop index I";
Command "create index I on T(c12)";
Command "select c12 from T order by c12 desc";
Command "drop index I";
Command "create index I on T(c11)";
Command "select c11 from T where c11 is null order by c11 asc";
Command "drop index I";
Command "create index I on T(c11)";
Command "select c11 from T where c11 = 'ja' order by c11 desc";
Command "drop index I";
Command "create index I on T(c6)";
Command "select c6 from T where c6 < 'aby' order by c6 desc";
Command "drop index I";
Command "create index I on T(c4)";
Command "select c4 from T where c4 > 'あえう' order by c4 desc";
Command "drop index I";
Command "create index I on T(c5)";
Command "select c5 from T where c5 is null order by c5 desc";
Command "drop index I";
Command "create index I on T(c6)";
Command "select c6 from T order by c6 desc";
Command "drop index I";
Command "create index I on T(c8)";
Command "select c8 from T where c8 >= 847865165 order by c8 desc";
Command "drop index I";
Command "create index I on T(c12)";
Command "select c12 from T where c12 = 1 order by c12 desc";
Command "drop index I";
Command "create index I on T(c5)";
Command "select c5 from T where c5 like 'ab%' order by c5 desc";
Command "drop index I";
Command "create index I on T(c4)";
Command "select c4 from T where c4 is null order by c4 desc";
Command "drop index I";
Command "create index I on T(c7)";
Command "select c7 from T where c7 is null order by c7 desc";
Command "drop index I";
Command "create index I on T(c6)";
Command "select c6 from T where c6 is null order by c6 desc";
Command "drop index I";
Command "create index I on T(c6)";
Command "select c6 from T where c6 = 'aby' order by c6 desc";
Command "drop index I";
Command "create index I on T(c9)";
Command "select c9 from T where c9 < 3.141592 order by c9 desc";
Command "drop index I";
Command "create index I on T(c7)";
Command "select c7 from T where c7 <= 123 order by c7 desc";
Command "drop index I";
Command "create index I on T(c4)";
Command "select c4 from T where c4 like 'あ%う' order by c4 desc";
Command "drop index I";
Command "create index I on T(c12)";
Command "select c12 from T where c12 is null order by c12 desc";
Command "drop index I";
Command "create index I on T(c5)";
Command "select c5 from T where c5 like 'ab%' order by c5 desc";
Command "drop index I";

## all rows index
Command "create all rows index I on T(c1_ar)";
Command "select c1_ar from T where c1_ar like 'ab%'";
Command "drop index I";
Command "create all rows index I on T(c11_ar)";
Command "select c11_ar from T where c11_ar > 'zh'";
Command "drop index I";
Command "create all rows index I on T(c2_ar)";
Command "select c2_ar from T where c2_ar = 'あいう' order by c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c10_ar)";
Command "select c10_ar from T where c10_ar is null order by c10_ar asc";
Command "drop index I";
Command "create all rows index I on T(c5_ar)";
Command "select c5_ar from T where c5_ar = 'abx' order by c5_ar desc";
Command "drop index I";
Command "create all rows index I on T(c9_ar)";
Command "select c9_ar from T where c9_ar = 3.141592 order by c9_ar asc";
Command "drop index I";
Command "create all rows index I on T(c3_ar)";
Command "select c3_ar from T where c3_ar is not null order by c3_ar asc";
Command "drop index I";
Command "create all rows index I on T(c7_ar)";
Command "select c7_ar from T order by c7_ar asc";
Command "drop index I";
Command "create all rows index I on T(c6_ar)";
Command "select c6_ar from T where c6_ar is null";
Command "drop index I";
Command "create all rows index I on T(c4_ar)";
Command "select c4_ar from T where c4_ar <= 'あえう' order by c4_ar desc";
Command "drop index I";
Command "create all rows index I on T(c11_ar)";
Command "select c11_ar from T where c11_ar >= 'zh' order by c11_ar asc";
Command "drop index I";
Command "create all rows index I on T(c12_ar)";
Command "select c12_ar from T where c12_ar = 1";
Command "drop index I";
Command "create all rows index I on T(c10_ar)";
Command "select c10_ar from T order by c10_ar desc";
Command "drop index I";
Command "create all rows index I on T(c8_ar)";
Command "select c8_ar from T where c8_ar = 123456789";
Command "drop index I";
Command "create all rows index I on T(c3_ar)";
Command "select c3_ar from T where c3_ar is null";
Command "drop index I";
Command "create all rows index I on T(c6_ar)";
Command "select c6_ar from T where c6_ar like 'ab%' order by c6_ar desc";
Command "drop index I";
Command "create all rows index I on T(c2_ar)";
Command "select c2_ar from T";
Command "drop index I";
Command "create all rows index I on T(c5_ar)";
Command "select c5_ar from T where c5_ar is null order by c5_ar desc";
Command "drop index I";
Command "create all rows index I on T(c3_ar)";
Command "select c3_ar from T where c3_ar is null order by c3_ar asc";
Command "drop index I";
Command "create all rows index I on T(c1_ar)";
Command "select c1_ar from T where c1_ar = 'abx' order by c1_ar asc";
Command "drop index I";
Command "create all rows index I on T(c5_ar)";
Command "select c5_ar from T where c5_ar like 'ab%' order by c5_ar desc";
Command "drop index I";
Command "create all rows index I on T(c7_ar)";
Command "select c7_ar from T where c7_ar is not null order by c7_ar desc";
Command "drop index I";
Command "create all rows index I on T(c12_ar)";
Command "select c12_ar from T where c12_ar = 1 order by c12_ar desc";
Command "drop index I";
Command "create all rows index I on T(c9_ar)";
Command "select c9_ar from T where c9_ar = 3.141592 order by c9_ar asc";
Command "drop index I";
Command "create all rows index I on T(c9_ar)";
Command "select c9_ar from T where c9_ar = 3.141592 order by c9_ar desc";
Command "drop index I";
Command "create all rows index I on T(c10_ar)";
Command "select c10_ar from T where c10_ar = '2007-02-01 12:34:56.789' order by c10_ar desc";
Command "drop index I";
Command "create all rows index I on T(c9_ar)";
Command "select c9_ar from T where c9_ar <> 1.414213 order by c9_ar desc";
Command "drop index I";
Command "create all rows index I on T(c2_ar)";
Command "select c2_ar from T where c2_ar is null order by c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c2_ar)";
Command "select c2_ar from T where c2_ar <= 'あえう' order by c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c3_ar)";
Command "select c3_ar from T where c3_ar = 'abx' order by c3_ar desc";
Command "drop index I";
Command "create all rows index I on T(c8_ar)";
Command "select c8_ar from T where c8_ar = 847865165 order by c8_ar desc";
Command "drop index I";
Command "create all rows index I on T(c10_ar)";
Command "select c10_ar from T where c10_ar is null order by c10_ar desc";
Command "drop index I";
Command "create all rows index I on T(c10_ar)";
Command "select c10_ar from T where c10_ar is not null order by c10_ar desc";
Command "drop index I";
Command "create all rows index I on T(c2_ar)";
Command "select c2_ar from T where c2_ar like 'あ%う' order by c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c5_ar)";
Command "select c5_ar from T where c5_ar = 'abx' order by c5_ar desc";
Command "drop index I";
Command "create all rows index I on T(c3_ar)";
Command "select c3_ar from T order by c3_ar desc";
Command "drop index I";
Command "create all rows index I on T(c12_ar)";
Command "select c12_ar from T where c12_ar <> -1 order by c12_ar desc";
Command "drop index I";
Command "create all rows index I on T(c2_ar)";
Command "select c2_ar from T where c2_ar = 'あえう' order by c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c10_ar)";
Command "select c10_ar from T where c10_ar is null order by c10_ar desc";
Command "drop index I";
Command "create all rows index I on T(c2_ar)";
Command "select c2_ar from T where c2_ar = 'あえう' order by c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c3_ar)";
Command "select c3_ar from T where c3_ar > 'abx' order by c3_ar desc";
Command "drop index I";
Command "create all rows index I on T(c8_ar)";
Command "select c8_ar from T where c8_ar is not null order by c8_ar desc";
Command "drop index I";
Command "create all rows index I on T(c9_ar)";
Command "select c9_ar from T where c9_ar is null order by c9_ar desc";
Command "drop index I";
Command "create all rows index I on T(c1_ar)";
Command "select c1_ar from T where c1_ar like 'ab%' order by c1_ar desc";
Command "drop index I";
Command "drop table T";
TerminateSession;
InitializeSession "TESTDB";
Command "drop database TESTDB";
TerminateSession;
Terminate;
End;
