# Bug report 1826
# 

Begin;
Initialize;
InitializeSession "TESTDB";
Command "create database TESTDB";
Command "create table TBL(f int array[16], g int not null)";
Command "create array index IDX_f on TBL(f)";
Command "create index IDX_g on TBL(g)";

Command "insert TBL values (array[1],1), (array[2],2), (array[3],3), (array[4],4), (array[5],5)";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";
Command "insert TBL select array[f[1]+1],g*2 from TBL";

Command "start explain no execute";

# IDX_gをスキャンしてfを評価
Command "select * from TBL where f[] < 5000 order by g";

# fの検索結果を得て後からソート
Command "select * from TBL where f[] < 0 order by g";

# fの検索結果を得て後からソートになるべきところがIDX_gをスキャンしてfを評価になってる
Command "select * from TBL where f[] > 50000 order by g";

Command "drop database TESTDB";

TerminateSession;
Terminate;
End;
