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と検索条件 追加テスト : 複合索引・2列
#

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(c2, c11)";
Command "select c2, c11 from T order by c2 desc";
Command "drop index I";
Command "create index I on T(c5, c8)";
Command "select c5, c8 from T order by c5 asc, c8 asc";
Command "drop index I";
Command "create index I on T(c6, c7)";
Command "select c6, c7 from T order by c6 asc, c7 asc";
Command "drop index I";
Command "create index I on T(c9, c4)";
Command "select c9, c4 from T order by c9 desc";
Command "drop index I";
Command "create index I on T(c10, c3)";
Command "select c10, c3 from T order by c10 desc";
Command "drop index I";
Command "create index I on T(c1, c12)";
Command "select c1, c12 from T order by c1 desc, c12 desc";
Command "drop index I";
Command "create index I on T(c2, c10)";
Command "select c2, c10 from T order by c2 asc";
Command "drop index I";
Command "create index I on T(c4, c8)";
Command "select c4, c8 from T order by c4 asc, c8 asc";
Command "drop index I";
Command "create index I on T(c5, c9)";
Command "select c5, c9 from T order by c5 asc";
Command "drop index I";
Command "create index I on T(c10, c2)";
Command "select c10, c2 from T order by c10 desc";
Command "drop index I";
Command "create index I on T(c4, c11)";
Command "select c4, c11 from T order by c4 asc, c11 asc";
Command "drop index I";
Command "create index I on T(c6, c10)";
Command "select c6, c10 from T order by c6 desc";
Command "drop index I";
Command "create index I on T(c7, c9)";
Command "select c7, c9 from T order by c7 asc, c9 asc";
Command "drop index I";
Command "create index I on T(c10, c5)";
Command "select c10, c5 from T order by c10 desc";
Command "drop index I";
Command "create index I on T(c12, c4)";
Command "select c12, c4 from T order by c12 asc, c4 asc";
Command "drop index I";
Command "create index I on T(c1, c3)";
Command "select c1, c3 from T order by c1 asc, c3 asc";
Command "drop index I";
Command "create index I on T(c4, c6)";
Command "select c4, c6 from T order by c4 desc";
Command "drop index I";
Command "create index I on T(c6, c11)";
Command "select c6, c11 from T order by c6 desc";
Command "drop index I";
Command "create index I on T(c8, c9)";
Command "select c8, c9 from T order by c8 asc";
Command "drop index I";
Command "create index I on T(c10, c7)";
Command "select c10, c7 from T order by c10 asc, c7 asc";
Command "drop index I";
Command "create index I on T(c11, c8)";
Command "select c11, c8 from T order by c11 desc, c8 desc";
Command "drop index I";
Command "create index I on T(c2, c3)";
Command "select c2, c3 from T order by c2 asc, c3 asc";
Command "drop index I";
Command "create index I on T(c4, c1)";
Command "select c4, c1 from T order by c4 desc";
Command "drop index I";
Command "create index I on T(c5, c4)";
Command "select c5, c4 from T order by c5 asc";
Command "drop index I";
Command "create index I on T(c7, c12)";
Command "select c7, c12 from T order by c7 desc, c12 desc";
Command "drop index I";
Command "create index I on T(c10, c12)";
Command "select c10, c12 from T order by c10 asc";
Command "drop index I";
Command "create index I on T(c12, c7)";
Command "select c12, c7 from T order by c12 desc, c7 desc";
Command "drop index I";
Command "create index I on T(c1, c8)";
Command "select c1, c8 from T order by c1 asc, c8 asc";
Command "drop index I";
Command "create index I on T(c5, c2)";
Command "select c5, c2 from T order by c5 asc";
Command "drop index I";
Command "create index I on T(c8, c7)";
Command "select c8, c7 from T order by c8 desc, c7 desc";
Command "drop index I";
Command "create index I on T(c9, c11)";
Command "select c9, c11 from T order by c9 desc";
Command "drop index I";
Command "create index I on T(c12, c5)";
Command "select c12, c5 from T order by c12 asc, c5 asc";
Command "drop index I";

## all rows index
Command "create all rows index I on T(c1_ar, c12_ar)";
Command "select c1_ar, c12_ar from T order by c1_ar asc";
Command "drop index I";
Command "create all rows index I on T(c3_ar, c10_ar)";
Command "select c3_ar, c10_ar from T order by c3_ar desc, c10_ar desc";
Command "drop index I";
Command "create all rows index I on T(c4_ar, c9_ar)";
Command "select c4_ar, c9_ar from T order by c4_ar desc, c9_ar desc";
Command "drop index I";
Command "create all rows index I on T(c7_ar, c6_ar)";
Command "select c7_ar, c6_ar from T order by c7_ar asc";
Command "drop index I";
Command "create all rows index I on T(c8_ar, c5_ar)";
Command "select c8_ar, c5_ar from T order by c8_ar asc";
Command "drop index I";
Command "create all rows index I on T(c11_ar, c2_ar)";
Command "select c11_ar, c2_ar from T order by c11_ar desc, c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c12_ar, c1_ar)";
Command "select c12_ar, c1_ar from T order by c12_ar desc, c1_ar desc";
Command "drop index I";
Command "create all rows index I on T(c3_ar, c11_ar)";
Command "select c3_ar, c11_ar from T order by c3_ar asc, c11_ar asc";
Command "drop index I";
Command "create all rows index I on T(c8_ar, c4_ar)";
Command "select c8_ar, c4_ar from T order by c8_ar asc";
Command "drop index I";
Command "create all rows index I on T(c9_ar, c5_ar)";
Command "select c9_ar, c5_ar from T order by c9_ar desc";
Command "drop index I";
Command "create all rows index I on T(c11_ar, c3_ar)";
Command "select c11_ar, c3_ar from T order by c11_ar asc";
Command "drop index I";
Command "create all rows index I on T(c2_ar, c8_ar)";
Command "select c2_ar, c8_ar from T order by c2_ar asc, c8_ar asc";
Command "drop index I";
Command "create all rows index I on T(c3_ar, c7_ar)";
Command "select c3_ar, c7_ar from T order by c3_ar desc, c7_ar desc";
Command "drop index I";
Command "create all rows index I on T(c5_ar, c6_ar)";
Command "select c5_ar, c6_ar from T order by c5_ar asc";
Command "drop index I";
Command "create all rows index I on T(c8_ar, c2_ar)";
Command "select c8_ar, c2_ar from T order by c8_ar desc, c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c9_ar, c1_ar)";
Command "select c9_ar, c1_ar from T order by c9_ar desc, c1_ar desc";
Command "drop index I";
Command "create all rows index I on T(c11_ar, c10_ar)";
Command "select c11_ar, c10_ar from T order by c11_ar asc";
Command "drop index I";
Command "create all rows index I on T(c2_ar, c6_ar)";
Command "select c2_ar, c6_ar from T order by c2_ar asc";
Command "drop index I";
Command "create all rows index I on T(c3_ar, c5_ar)";
Command "select c3_ar, c5_ar from T order by c3_ar desc, c5_ar desc";
Command "drop index I";
Command "create all rows index I on T(c5_ar, c12_ar)";
Command "select c5_ar, c12_ar from T order by c5_ar asc";
Command "drop index I";
Command "create all rows index I on T(c7_ar, c4_ar)";
Command "select c7_ar, c4_ar from T order by c7_ar desc, c4_ar desc";
Command "drop index I";
Command "create all rows index I on T(c9_ar, c8_ar)";
Command "select c9_ar, c8_ar from T order by c9_ar desc";
Command "drop index I";
Command "create all rows index I on T(c12_ar, c10_ar)";
Command "select c12_ar, c10_ar from T order by c12_ar asc, c10_ar asc";
Command "drop index I";
Command "create all rows index I on T(c1_ar, c5_ar)";
Command "select c1_ar, c5_ar from T order by c1_ar asc";
Command "drop index I";
Command "create all rows index I on T(c3_ar, c2_ar)";
Command "select c3_ar, c2_ar from T order by c3_ar desc, c2_ar desc";
Command "drop index I";
Command "create all rows index I on T(c6_ar, c2_ar)";
Command "select c6_ar, c2_ar from T order by c6_ar desc";
Command "drop index I";
Command "create all rows index I on T(c8_ar, c11_ar)";
Command "select c8_ar, c11_ar from T order by c8_ar asc, c11_ar asc";
Command "drop index I";
Command "create all rows index I on T(c11_ar, c6_ar)";
Command "select c11_ar, c6_ar from T order by c11_ar asc, c6_ar asc";
Command "drop index I";
Command "create all rows index I on T(c2_ar, c1_ar)";
Command "select c2_ar, c1_ar from T order by c2_ar desc, c1_ar desc";
Command "drop index I";
Command "create all rows index I on T(c6_ar, c3_ar)";
Command "select c6_ar, c3_ar from T order by c6_ar desc";
Command "drop index I";
Command "create all rows index I on T(c7_ar, c1_ar)";
Command "select c7_ar, c1_ar from T order by c7_ar asc, c1_ar asc";
Command "drop index I";
Command "create all rows index I on T(c11_ar, c12_ar)";
Command "select c11_ar, c12_ar from T order by c11_ar desc, c12_ar desc";
Command "drop index I";
Command "create all rows index I on T(c1_ar, c9_ar)";
Command "select c1_ar, c9_ar from T order by c1_ar asc";
Command "drop index I";
Command "drop table T";
TerminateSession;
InitializeSession "TESTDB";
Command "drop database TESTDB";
TerminateSession;
Terminate;
End;
